scriptygoddess

23 Dec, 2003

Yearly Comment Leader Script

Posted by: Jennifer In: MT hacks

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

December 23rd, 2003 at 10:34 pm

Avatar

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

3 | Jennifer

December 23rd, 2003 at 10:41 pm

Avatar

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

4 | jrh

March 31st, 2005 at 7:36 pm

Avatar

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

April 6th, 2005 at 2:57 pm

Avatar

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

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements