View Full Version : help me, users average posts
khaleejy
10-08-2002, 11:32 AM
hi :)
how can i know all users average posts???
thanks
Xenon
10-08-2002, 11:34 AM
Huh?
can you explain what you meant by average posts?
Sorry, but i don't understand what you mean.
khaleejy
10-08-2002, 11:40 AM
lets say that i have 3 users
the first user posts 2 messages on the forum only
the second user posts 1 messages on the forum only
the 3d user posts 5 messages on the forum
the average = (2 + 1 + 5) / 3 = 8 / 3 = 3 post per user
can me to do that??
Xenon
10-08-2002, 12:48 PM
ahhh, i see
that wouldn't be a problem
where do you want to put it?
if you want to put it on the forumhomepage open index.php
find this: $numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=number_format($numbersmembers['users']);
// get total posts
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=number_format($countposts['posts']);
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=number_format($countthreads['threads']);
and below add this:
$avposts= round($totalposts/$numbermebers);
then you can use $avposts in your forumhome template
khaleejy
10-08-2002, 01:31 PM
thank you
but i dont want to show it in the main page.. i want to show it admin/index.php (admin cp home page)
thats what ive done:
<p><font size='1'>From here, you can control all aspects of your vBulletin forums.
Please select what you need from the links down the left hand side of this page.</font><p>
<?php
ive add below it the following:
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=$numbersmembers['users'];
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=$countposts['posts'];
$avposts = $totalposts / $numbermebers;
$avposts = round($avposts, 2);
echo "<br>Average users posts is (".$avposts.") per user";
but avposts will return to zero. and im getting this warning:
Warning: Division by zero
why it become zero??
Xenon
10-08-2002, 03:45 PM
$avposts = $totalposts / $numbermebers;
you've forgotten an 'm' in $numbermembers ^^
khaleejy
10-08-2002, 06:03 PM
thank you :) and sorry for this stupid mistake :knockedout:
Xenon
10-08-2002, 09:32 PM
;)
you're welcome
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.