|  | Posted by frizzle on 04/25/06 21:07 
Hi there!
 I'd like to create a function which input is the result of a mySQL
 query.
 The output should be exactly the same, only not a mySQL result array,
 but a 'real' array.
 So it should also get the fieldnames returned by mySQL and use those as
 keys.
 
 I can't get things to work properly: it should return a
 multidimensional array,
 like
 
 $result_array[1] = array(
 [field1] => field1 value,
 [field2] => field2 value,
 etc.
 )
 
 somehow my result is (with code below)
 
 $result_array[1] = array(
 [0] => field1 value,
 [field1] => field1 value,
 [1] =>  field2 value,
 [field2] => field2 value,
 etc.
 )
 
 Hope someone can help me on this one.
 
 Frizzle.
 
 
 +++++ code ++++++
 
 $get_res	= mysql_query(QUERY);
 
 if( $res = mysql_fetch_array( $get_res ) )
 {
 
 do{
 
 $result[] = $res;
 
 }while( $res = mysql_fetch_array( $get_res ) );
 
 };
 
 foreach( $result as $key => $value ){
 
 print_r($value);
 
 };
  Navigation: [Reply to this message] |