我想做一些国家统计
<?php
$country = mysql_query("SELECT * FROM b_visits WHERE link='$link'");
while($c = mysql_fetch_array($country)){
$code = $c['c_code'];
$name = $c['c_name'];
$broj = mysql_num_rows(mysql_query("SELECT * FROM b_visits WHERE link='$link' AND c_code='$code'"));
echo "<tr> <td><img style='max-width:20px;max-height:20px;' src='/flags/$code.png'> $name (<b>$broj</b>) </td> </tr>";
} ?>
和它一样:
美国(1) 未知(2) 未知(2)
就像你可以看到我得到2次同一个国家的帖子我想要的东西:
未知(2)
United Stats(1)等。
任何帮助?
答案 0 :(得分:0)
试试这个:
<?php
$country = mysql_query("SELECT c_name, count(c_name) as count FROM b_visits WHERE link='$link' group by c_name");
while($c = mysql_fetch_array($country)){
$broj = $c['count'];
$name = $c['c_name'];
echo "<tr> <td><img style='max-width:20px;max-height:20px;' src='/flags/$code.png'> $name (<b>$broj</b>) </td> </tr>";
} ?>