after these for example
$result = mysql_query("SELECT id, name FROM mytable")
i tried to echo back this
$row=mysql_fetch_array($results, MYSQL_ASSOC);
when i did run the query in my PHPmyadmin SQL command it came back with several lines in columns (three) from the table but when i echo back $row it give back just one line
<?php echo print_r($row); ?>
You need to continuously call mysql_fetch_array()
until it returns false
, as the function returns the current row and moves the internal pointer ahead. A return value of false
means you have iterated through all the rows:
while($row = mysql_fetch_array($results, MYSQL_ASSOC))
{
// do something with $row
}