[英]Display Result of MYSQL Count
I'm using a query to output a list of members of a shoutbox and their shout count: 我正在使用查询输出一个shoutbox成员列表及其喊叫次数:
SELECT user_id, COUNT( * ) AS Shouts
FROM shouts
GROUP BY user_id
ORDER BY Shouts DESC
Which displays: 哪个显示:
User1: 3490 用户1:3490
User2: 1234 用户2:1234
User3: 345 用户3:345
... ...
I've tried the following: 我尝试过以下方法:
$result = mysql_query(the query above);
$count = mysql_fetch_array($result);
echo $count['Shouts'];
but it only displays the first row. 但它只显示第一行。 How can I display the whole result?
如何显示整个结果?
You need to put the mysql_fetch_array within a loop: 你需要把mysql_fetch_array放在一个循环中:
while ($count = mysql_fetch_array($result)) {
echo $count['Shouts'];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.