Top X Commenters

Last modified: July 3, 2009 - 17:17

<?php
$users
= db_query("SELECT COUNT(cid) AS count, name, uid FROM {comments} WHERE uid != 1 and uid != 0 GROUP BY uid ORDER BY count DESC LIMIT 10");

$output = "<ul>";
while (
$user = db_fetch_object($users)) {
 
$output .= "<li>" . l($user->name, drupal_get_path_alias("user/{$user->uid}")). " ($user->count)</li>";
}
$ouput .= "</ul>";
echo
$output;
?>

To change the number of users shown, simply change the "LIMIT 10" clause to whatever amount of users you wish to display.

Currently excludes both the administrative (user 1) and anonymous user (user 0). You can adjust the WHERE clause as desired to change this.

 
 

Drupal is a registered trademark of Dries Buytaert.