| 
	
 | 
 Posted by frizzle on 04/25/06 22:32 
David Haynes wrote: 
> frizzle wrote: 
> > 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. 
> > 
> My assumption was that one column in the table being queried formed the 
> keys for the associative array. If so, then my method works. If not, 
> what were you planning on using as the key to the array? 
> 
> -david- 
 
Having read it again and again i get it. 
ideally, it would check if there is an 'id' in the returned fields and 
use that 
as index ... 
 
Frizzle.
 
  
Navigation:
[Reply to this message] 
 |