Posted by frizzle on 04/25/06 22:24
David Haynes wrote:
> $result[] = causes the result to be pushed onto an indexed array not an
> associative array. See inline for fix.
>
> -david-
> >
> > $get_res = mysql_query(QUERY);
> >
> > if( $res = mysql_fetch_array( $get_res ) )
> > {
> >
> > do{
> >
> $result[$res['field1']] = $res['field1 value'];
> >
> > } while( $res = mysql_fetch_array( $get_res ) );
> >
> > };
> >
> > foreach( $result as $key => $value ){
> >
> > print_r($value);
> >
> > };
David,
i don't alwas know all fieldnames beforehand.
So SELECT * should also put all fieldnames as
keys in the array.
Frizzle.
[Back to original message]
|