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”;
}
?>
This entry was posted
on Tuesday, December 23rd, 2003 at 10:52 am and is filed under MT hacks.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.
December 23rd, 2003 at 10:34 pm
this looks great!! can’t wait to try it…
but you need to close quotes on the end of your url’s…*s*
December 23rd, 2003 at 10:40 pm
Which urls?
December 23rd, 2003 at 10:41 pm
Ahh - nevermind - I see it. Problem with copying and pasting a post from a web-mail-reader…
March 31st, 2005 at 7:36 pm
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.
April 6th, 2005 at 2:57 pm
hi! i hate to fend off the prodigious flow of help, but i worked something out. thanks anyway.