cotonti.com : Help on a plugin that shows top posters https://www.cotonti.com Son konu mesajları Cotonti en Mon, 13 Oct 2025 21:39:09 -0000 Twiebie Thanks for the quick reply, Trustmaster!

Got it working now. :)

]]>
Sal, 31 Tem 2012 18:37:22 -0000
Trustmaster The users table does not keep history information, so you cannot extract statistics for a given time span. Instead, the information should be extracted from the forum posts table. The query for top 10 posters for the last 7 days looks like this:

SELECT u.user_id, u.user_name, u.user_avatar, COUNT(p.fp_id) AS count
    FROM `$db_forum_posts` AS p
        LEFT JOIN `$db_users` AS u ON p.fp_posterid = u.user_id
    WHERE fp_creation > UNIX_TIMESTAMP() - 7*24*3600
    GROUP BY fp_posterid
    ORDER BY count DESC
    LIMIT 10
]]>
Sal, 31 Tem 2012 18:11:16 -0000
Twiebie I want to create a little plugin that shows the weekly top posters in a list.

I've grabbed a bit of code from the forum stats plugin to get started, but now i'm wondering how I can get/specify the users post count for a specific timespan (a week for example).

$res = $db->query("SELECT user_id, user_name, user_postcount FROM $db_users WHERE 1 ORDER by user_postcount DESC LIMIT 10");

foreach ($res->fetchAll() as $row) {
	$t1->assign(array(
		'TOPPOSTERS_NAME' => cot_build_user($row['user_id'], htmlspecialchars($row['user_name'])),
		'TOPPOSTERS_POSTS' => $row["user_postcount"],
	));
}

Thanks.

]]>
Sal, 31 Tem 2012 17:53:24 -0000