Possible Duplicate:
MySQL returns only one row
In Terminal
mysql> select image,title,price from test;
db result:
image title price
1 2 3
4 5 6
But, In PHP
.
.
$query=mysql_query("select image,title, price from test",$connect);
$row=mysql_fetch_object($query);
print json_encode($row);
result:
image= 1, title = 2 , price=3
why don’t print image=4 title=5 price=6?
how?
If you look at the PHP documentation for
mysql_fetch_object(), its purpose is to “Fetch a result row as an object.” You have to keep calling until there are no more rows:Also notice I renamed the return value of
mysql_query()to$result, as that’s a bit more correct.