Yearly Comment Leader Script

I just implemented the comment leaderboard script available here, but I wanted to feature the *yearly* comment leaders as opposed to the monthlies. I tinkered with it and lo and behold, it actually worked!

Replace the bold text with your own paths, e-mail address, author name, and blog id. You can adjust the number of leaders shown as well; the default is ten. You’ll need the connect.php file in order for this script to work — info is available at The Girlie Matters.

<? include (”/PATH/TO/YOUR/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 !=’E-MAIL ADDRESS YOU USE ON YOUR BLOG‘ AND comment_author !=’NAME YOU USE ON YOUR BLOG‘) 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 comments this year<br />\n”;
}
?>

5 Responses to “Yearly Comment Leader Script”

  1. Redeagle Says:

    this looks great!! can’t wait to try it…
    but you need to close quotes on the end of your url’s…*s*

  2. Jennifer Says:

    Which urls?

  3. Jennifer Says:

    Ahh - nevermind - I see it. Problem with copying and pasting a post from a web-mail-reader…

  4. jrh Says:

    hi. i had the comment leaders working for MT 2.x, and have had the blogs down for almost a year. now, i’ve had a friend help me out with upgrading to 3.15, which i have working now. will comment leaders still work for MT 3.15? if so, will the code above work? thank you in advance, assuming you still have time to answer comments.

  5. jrh Says:

    hi! i hate to fend off the prodigious flow of help, but i worked something out. thanks anyway.