我还需要让发送邮件计数的用户。
$userlist = mysql_query("select count(distinct m.subject) as msgcnt, u.name from message as m, message_users as mu, users as u where m.owner_id = u.id and m.id=mu.msg_id and mu.user_id='$u_id'group by name") or mysql_error();
while($row=mysql_fetch_array($userlist))
{
echo $row['name']."<br />";
}
如何使用while循环获取计数值..
答案 0 :(得分:3)
您已将所述计数存储在别名msgcnt
中,只需将其回显即可。
while($row=mysql_fetch_assoc($userlist))
{
echo $row['name']." : ".$row['msgcnt']."<br />";
}
答案 1 :(得分:1)
echo $row['msgcnt'].'<br/>';
答案 2 :(得分:0)
使用mysql_fetch_assoc
获取关联的数组!
$userlist = mysql_query("select count(distinct m.subject) as msgcnt, u.name from message as m, message_users as mu, users as u where m.owner_id = u.id and m.id=mu.msg_id and mu.user_id='$u_id'group by name") or mysql_error();
while($row=mysql_fetch_assoc($userlist)) {
echo $row['name']."<br />";
echo $row['msgcnt']."<br />";
}
答案 3 :(得分:0)
在您将别名指定为msgcnt
msgcnt
echo $row['msgcnt']."<br />";