我正在使用查询输出一个shoutbox成员列表及其喊叫次数:
SELECT user_id, COUNT( * ) AS Shouts
FROM shouts
GROUP BY user_id
ORDER BY Shouts DESC
显示:
用户1:3490
用户2:1234
用户3:345
...
我尝试了以下内容:
$result = mysql_query(the query above);
$count = mysql_fetch_array($result);
echo $count['Shouts'];
但它只显示第一行。如何显示整个结果?
答案 0 :(得分:2)
你需要把mysql_fetch_array放在一个循环中:
while ($count = mysql_fetch_array($result)) {
echo $count['Shouts'];
}