I have a table in my database called cms_privatemessage. I am trying to display stats in my admin panel of my CMS, and would like to display the user who has the most PM's and also show the number which they have.
The 'userto' column is where the recipients name is stored.
This is what I have tried but it fails to work.
$result = mysql_query("SELECT userto, COUNT(*) FROM cms_privatemessage GROUP BY userto");
$row = mysql_fetch_assoc($result);
$pm_count = mysql_num_rows($result);
$user = $row[userto];
echo '<font color ="#FF3300">' . $user . ' - ' . $pm_count . ' PM\'s</font>';