I need to get the users who sends the message count as well.
$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 />";
}
How to get the count values by using while loop..
You already are storing the said count in an alias msgcnt
, simply echo it.
while($row=mysql_fetch_assoc($userlist))
{
echo $row['name']." : ".$row['msgcnt']."<br />";
}
echo $row['msgcnt'].'<br/>';
use mysql_fetch_assoc
to get a associated array!
$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 />";
}
使用msgcnt
时指定别名msgcnt
echo $row['msgcnt']."<br />";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.