Page 1 of 1

Fetch Array

Posted: Wed Feb 06, 2008 9:13 am
by laloto
~pickle | Please use [ php ] tags where appropriate. Your post has been updated to reflect how we'd like it to look.
Hi you smarts!
I need to extract the info from different row from an array created by :

Code: Select all

$autores = mysql_query($query_autores, $conetion) or die(mysql_error());
$row_autores = mysql_fetch_assoc($autores);
And then asign the info OF EACH ROW to some different variables.
I'd try this, but it doesnot work on mozila, only in IE.

Code: Select all

$var2 = mysql_fetch_assoc($autores);
$var3 = mysql_fetch_assoc($autores);
$var4 = mysql_fetch_assoc($autores);
and then:

Code: Select all

echo ($var2['id']);
echo ($var3['id']);
echo ($var4['id']);
( i dont know how to do it using a "while", because i need same field of diferents rows in diferent variables)

Please help.
~pickle | Please use [ php ] tags where appropriate. Your post has been updated to reflect how we'd like it to look.

Re: Fetch Array

Posted: Wed Feb 06, 2008 11:05 am
by Kieran Huggins
instead, try:

Code: Select all

$i = 0;
while($row = mysql_fetch_assoc($autores)){
   echo $results[$i]['col1'];
   echo $results[$i]['col2'];
   // ...etc
   $i++;
}
 
print_r($results);

Re: Fetch Array

Posted: Wed Feb 06, 2008 2:36 pm
by laloto
:D
Yes it does Works, thank you very much Kieran Huggins.
laloto