Comment leaders for the current month

| tutorials | | Comments (0)

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!

About this Entry

This page contains a single entry by Lisa published on April 18, 2003 4:31 PM.

Pictures and more pictures! was the previous entry in this blog.

Evening cuteness alert is the next entry in this blog.

Find recent content on the main index.

Me!

"My answer is that insanity is communicable, especially over the internet." - wanderingwidget
"Ah, so it's a textually transmitted disease, then?" -rhi_silverflame

About me... :: memes :: My Amazon wishlist :: My LJ :: My Twitter :: My Flickr :: Photos of me

Blog reading list

Contacts
· AIM, Yahoo!, MSN, Google Talk, LJ Talk... just ask
· Email me

Good Causes

       
Love is love.
Support gay marriage.

platinum.gif
East siiiiiiiiiiiiiiiiiiiide, baby!
Click to help
sponsor mammograms
Listen to good music! Radio Paradise

Silly Stuff

blogchalk:
Lisa/Female/41-45. Lives in United States/Mass/Boston and speaks
English. Spends 80% of daytime online. Uses a Faster (1M+) connection.
The
WeatherPixie
The weather in Boston

Flickr

www.flickr.com
jasra's photos More of jasra's photos
Powered by Movable Type 4.1

Copyright

Copyright © 2001-7 Lisa K Holsberg. Unauthorized use is prohibited.