MyBB Community Forums

Full Version: [Suggestions?] - Posts/Threads/Members per day over last week
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I decided to modify stats.php to show posts/threads/members per day over the last week.

But, the page generation times for Forums Stats is a little slow - since I'm new to PHP/SQL etc, just wondering, is there a faster method?

This is the code I'm using:
// average over past week
$lastweekdate = (time()-60*60*24*7);
$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(pid) AS tot", "dateline >= ".$lastweekdate);
$result = $db->fetch_array($query);
$postsperdaylastweek = my_number_format(round(($result['tot'] / 7), 2));
$query = $db->simple_select(TABLE_PREFIX."threads", "COUNT(tid) AS tot", "dateline >= ".$lastweekdate);
$result = $db->fetch_array($query);
$threadsperdaylastweek = my_number_format(round(($result['tot'] / 7), 2));
$query = $db->simple_select(TABLE_PREFIX."users", "COUNT(uid) AS tot", "regdate >= ".$lastweekdate);
$result = $db->fetch_array($query);
$membersperdaylastweek = my_number_format(round(($result['tot'] / 7), 2));

Page generation times aren't bad, but I'd prefer them to be quicker - can this be optimized (by simple means) any more?

Thanks a lot for any replies Smile