Many forums have a feature that shows posts per day for a given user.
How do they calculate that number?
Many forums have a feature that shows posts per day for a given user.
How do they calculate that number?
I'm not sure what you're asking. They have in their database a complete lists of posts, who posted them, and when the poster registered, so it's just division. Someone who registered 3 days ago and has 12 posts has posted 4 times/day
The posts are stored in a database, with a timestamp. Just as on this forum. Then it simply becomes a trivial SQL query (or it is placed in the business logic layer) to find the posts on a particular day.
SELECT Count(*) As Total FROM tblPosts
INNER JOIN tblUsers ON tlbPosts.UserId = tblUsers.UserId
WHERE PostDate > tblUsers.RegistrationDate AND PostDate < Today
The result should be divided by the number of days in the period you want the average of.
Forums mostly record posts along with date in one row, of course there are user information too. Then the information about all posts is compared with user registration date and depending on results you get your answer.
Well, actually not sure if many forums use that, but I have used this before and some easy forums have same solution. (Since it's long since I've used phpBB or any other free well-built forums, I cannot give you a perfect match!)
<?php
// test data
$registerDate = strtotime("2010-03-01");
$totalPosts = 500;
// calculation
$days = round((time() - $registerDate) / 86400);
$postsPerDay = round($totalPosts / $days);
// output
echo "Posts per day: " . $postsPerDay;
?>
Number of posts divided by the number of days the user has been a member?