Comment leaders for the current month
This is a variation of Girlie's Comment Leaderboard. I've seen other people who show the comment leaders for the last 30 days, but I decided I'd rather show the leaders for the current month.
Here's the code. The items bolded and underlined need to be changed to reflect your blog settings.
<? include ("/path/to/your/connection/file/connect.php");
$leaders = mysql_query("SELECT comment_email, comment_url, comment_author, COUNT(*) as comment_count FROM mt_comment WHERE (comment_blog_id=1) AND (comment_email!='you@yourdomain.com') AND MONTH(comment_created_on) = MONTH(CURDATE()) AND YEAR(comment_created_on) = YEAR(CURDATE()) GROUP BY comment_author, comment_email ORDER BY comment_count DESC LIMIT 10");
while($row = mysql_fetch_array($leaders)) {
while (list($key,$val) = each($row)) {$$key = $val;}
if (!empty($comment_url)) {
$authorlink = "<a href=\"$comment_url\">$comment_author</a>";
} elseif(!empty($comment_email)) {
$authorlink = "<a href=\"mailto:$comment_email\">$comment_author</a>";
} else {$authorlink = $comment_author;}
echo "$authorlink ($comment_count)<br />\n";
}
?>
/path/to/your/connection/file/connect.php = location of your connect.php file
1 = your blog ID
you@yourdomain.com = your email address (so that your comments aren't counted)
10 = number of leaders to show
Text version of code (right-click and save to your computer)
Susan of Says Me noticed that her comments were getting counted with Susan of Sue's Bloggy Blog. I fixed the "GROUP BY" statement to take into account both name & email address. Thanks, Susan!




