Help - Search - Members - Calendar
Full Version: Forum Statistics
Weborum Webmaster Forum > Web Page Design > PHP
garrgoyle
I Found this website, here, that has something I really like on it, but im not sure (ok, I actually don't have a clue.) how it works.

What it is, is at the bottom, it has forum statistics, with the number of posts and members and stuff. Any ideas how I could get something like that on my site?

Thanks
garrgoyle
oops, sorry posted this in completely the wrong forum, lol, sorry!
aviansuicide
Simple...:

CODE


SELECT count(members.*) as members,count(posts.*) as posts,count(topics.*) as topics,count(online.*) as online FROM members_table members,posts_table posts,topics_table topics,online_table online



replace members_table with your users table,posts_table with your forum posts table,topics_table with your topics(threads) table,online_table with your 'who's online' table.
PHP

<?
/* connect to db,etc */

$query = mysql_query("SELECT count(members.*) as members,count(posts.*) as posts,count(topics.*) as topics,count(online.*) as online FROM members_table members,posts_table posts,topics_table topics,online_table online");

$row = mysql_fetch_array($query);

foreach(
$row as $key => $val)
{
echo
$key.' : '.$val.'<br/>';
}
?>


garrgoyle
i know im a complete pain in the ass, but i dont know what u mean by this whole sentence lol:

"replace members_table with your users table,posts_table with your forum posts table,topics_table with your topics(threads) table,online_table with your 'who's online' table."
aviansuicide
well..your members table I assume isn't called "members_table"..so replace "members_table" with the name of the table.Likewise for your posts,topics and online users tables
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.