Fetch Array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
laloto
Forum Newbie
Posts: 2
Joined: Wed Feb 06, 2008 8:53 am

Fetch Array

Post 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.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Fetch Array

Post 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);
laloto
Forum Newbie
Posts: 2
Joined: Wed Feb 06, 2008 8:53 am

Re: Fetch Array

Post by laloto »

:D
Yes it does Works, thank you very much Kieran Huggins.
laloto
Post Reply