|  | Posted by Rik on 08/15/06 10:34 
monomaniac21 wrote:> hi all
 >
 > im querying a db for two rows which are always returned. how can i
 > reference each row and output its contents without using a while loop.
 > ive tried:
 >
 > $row = mysql_fetch_array($result);
 > extract $row;
 > echo $var1[0]; //var 1 of row 0
 > echo $var1[1]; //var 1 of row 1
 
 Nope, it won't.
 You only retrieve 1 row, you call mysql_fetch_array just once.
 Furthermore, extract will create vartiables named after you fieldnames or
 aliasses deriving from the query.
 
 I think you're looking for this:
 $row0var1 = mysql_result($result,0,0); (or: mysql_result($result,0); for the
 first value)
 $row1var1 = mysql_result($result,1,0);
 
 Grtz,
 --
 Rik Wasmus
 [Back to original message] |