表caifuc有uid tid type 字段。我在输出的时候如何得到tid相同的值的总数?如得到TID字段值15091 的总数为4条记录?uid tid type
76 15087 2
76 15091 7
76 14866 1
76 15082 3
76 15091 3
76 15091 8
76 15091 2
76 15082 1
76 15087 2
76 15091 7
76 14866 1
76 15082 3
76 15091 3
76 15091 8
76 15091 2
76 15082 1
PHP我不知道怎么写.呵呵。
mysql_connect('localhost','username','password');
mysql_select_db('mydb');
$result = mysql_query('SELECT `tid`, COUNT(`tid`) FROM `caifuc` GROUP BY `tid`');
if ($result && mysql_num_rows($result) > 0)
{
while ($row = mysql_fetch_row($result))
{
echo 'tid: ', $row[0], ' num: ', $row[1], '<br/>';
}
}
上面只是思路!