回应每个结果的计数

时间:2010-09-17 23:38:55

标签: php

这个PHP / MySQL从我的数据库获得顶级推特:

$toptweeters = mysql_query("SELECT count(user) a,user from fotetweets group by user order by a desc limit 10");
    while ($row = mysql_fetch_assoc($toptweeters)) {
            echo "<li style='border: 0; margin-left: 5px;'><a target='_blank' style='border: 0;' href='http://twitter.com/".$row["user"]."'>";
            echo $row["user"];
            echo "</a></li>";
    }

如何显示返回的每个用户的计数结果?

2 个答案:

答案 0 :(得分:2)

你有:

echo $row["user"];

写入insetad ::

echo $row["user"] . ": " . $row["a"];

答案 1 :(得分:0)

我认为这就是你要找的东西:

$toptweeters = mysql_query("SELECT count(user) AS `a`, `user`  FROM `fotetweets` GROUP BY `user` ORDER BY `a` DESC LIMIT 10");
while ($row = mysql_fetch_assoc($toptweeters)) {
        echo "<li style='border: 0; margin-left: 5px;'><a target='_blank' style='border: 0;' href='http://twitter.com/".$row["user"]."'>";
        echo $row["user"];
        echo $row["a"];
        echo "</a></li>";
    }