Reputation: 3363
This is the query
$db=mysql_connect('localhost','root','root');
mysql_select_db('test');
$query=mysql_query("SELECT * FROM table");
$r=mysql_fetch_assoc($query);
print_r($r);
It only gives me the first element.
But in PhpMyAdmin it gives me all the elements.
How can I make it work in PHP?
Upvotes: 0
Views: 60
Reputation: 1911
mysql_fetch_assoc
fetches one row per function call. What you want is probably:
while($r = mysql_fetch_assoc($query)){
print_r($r);
}
Upvotes: 2