scriptygoddess

19 Apr, 2003

Comment leaders for the current month

Posted by: Lisa In: How to's

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

April 19th, 2003 at 11:53 pm

Avatar

Would this also work for Greymatter??

2 | Lisa, Gal of Unix

April 19th, 2003 at 11:56 pm

Avatar

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

April 20th, 2003 at 12:02 am

Avatar

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 | Jake

April 24th, 2003 at 1:41 am

Avatar

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

5 | Jaime

May 5th, 2003 at 12:53 am

Avatar

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

6 | Jake

June 15th, 2003 at 5:51 pm

Avatar

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?

7 | Lisa, Gal of Unix

June 15th, 2003 at 5:56 pm

Avatar

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

8 | Kestrel

June 4th, 2004 at 2:48 am

Avatar

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

9 | Jennifer

June 4th, 2004 at 7:38 am

Avatar

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…)

10 | Neurotic Fishbowl

April 20th, 2003 at 8:36 pm

Avatar

Monthly Comment Leaders
If you look in the sidebar, you'll see a new section under comment leaders that shows the people with the

11 | WE ARE HUGH

April 21st, 2003 at 2:28 pm

Avatar

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."

12 | Bloggie Broad

December 1st, 2003 at 6:32 pm

Avatar

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…

13 | Bloggie Broad

December 1st, 2003 at 6:53 pm

Avatar

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…

14 | Bloggie Broad

December 2nd, 2003 at 4:27 pm

Avatar

*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…

15 | Code Novice

April 15th, 2004 at 12:19 am

Avatar

Yearly Comment Leaderboard
NOTE: I've only revised a few scripts here and there,…

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