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

Update: I added “, comment_email” to the “GROUP BY” section so that it will group by name and email address and not lump people who leave comments with the same name together.

15 Responses to “Comment leaders for the current month”

  1. Jake Says:

    Would this also work for Greymatter??

  2. Lisa, Gal of Unix Says:

    It depends if Greymatter keeps the data in a database. You’ll probably have to change things to match your table schema. If you can find db info for Greymatter, I can take a peek.

  3. Jake Says:

    Are there things for GM that allow most recent posts section etc…. if so where cna I find them I am searching with google, but that is all I am doing .. searching.

  4. Neurotic Fishbowl Says:
    Monthly Comment Leaders
    If you look in the sidebar, you’ll see a new section under comment leaders that shows the people with the

  5. WE ARE HUGH Says:
    Comment leaders for the current month
    scriptygoddess: “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.”

  6. Jake Says:

    hmm, I have no idea how they keep it. At that point I am lost and do not even know what to show ya.

  7. Jaime Says:

    What am I doing wrong when I get this code?

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/username/public_html/index.php on line 205

  8. Jake Says:

    I have switched to MT, and thought this script was written for that, but I cannot find the connect.php that it points too.

    Any pointers?

  9. Lisa, Gal of Unix Says:

    The connect.php file can be found at the girlie matters site.

  10. Bloggie Broad Says:
    Reverb: Bloggie Scripty Fun
    I’m organizing BB and deleted the posts revolving around my techie mess from earlier in the week, since it was an easy fix. I like…

  11. Bloggie Broad Says:
    Subscriptions and so much more!
    I fixed the comment subscriptions, so y’all should be set now. I’m not currently using MT-Blacklist, so I need to know if subscribers have any…

  12. Bloggie Broad Says:
    *Yearly* Comment Leaderboard
    I just implemented the comment leaderboard script available at Scriptygoddess, but I wanted to feature the *yearly* comment leaders as opposed to the monthlies. I…

  13. Code Novice Says:
    Yearly Comment Leaderboard
    NOTE: I’ve only revised a few scripts here and there,…

  14. Kestrel Says:

    I tried to add this plugin but got the errors listed below. The only things I changed were my username, password, and the path to the connect.php. Any ideas for what I’m doing wrong?

    —-
    Warning: main(): stream does not support seeking in /path/to/my/file/footer.inc on line 157

    Warning: mysql_connect(): Access denied for user: ‘xxxx@localhost’ (Using password: YES) in /path/to/my/file/connect.php on line 6
    I cannot connect to the database.
    Warning: mysql_query(): Access denied for user: ‘xxxxx@localhost’ (Using password: NO) in /path/to/my/file/footer.inc on line 159

    Warning: mysql_query(): A link to the server could not be established in /path/to/my/file/footer.inc on line 159

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /path/to/my/file/footer.inc on line 161

    -

  15. Jennifer Says:

    I would follow the error messages one line at a time… (ie. Start trying to figure out what is on line 157 and work from there…)