Small PHP Question

Forum
Last Post
Threads / Messages

snowman01

Member
Member
Joined
Feb 7, 2008
Messages
13
Points
0
Mysidian Dollar
0
Is there a PHP code to use to show the number of forums hosted? Like wherever I place the code it would say something like "Currently hosting *insert number here* forums!".
 
Well, take a look at the script below I made a while ago. It outputs your site stats including forums, users, posts, etc. :)

PHP:
<?php
include("create/mconfig.php");

//Connect to database...
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ("Cannot Authenticate to Database");
mysql_select_db($dbname);

//Loop through and get stats...

$posts = 0;
$users = 0;


$query = "SELECT * FROM hosted_forums";
$result = mysql_query($query);
$num = mysql_numrows($result);

//Loop out code
$i=0;
while ($i < $num) {

//Grab the forum name
$fname=@mysql_result($result,$i,"fname");

//Loop through and see how many posts and users each forum has...

    $query2 = "SELECT * FROM ".$fname."_posts";
    $result2 = mysql_query($query2);
    $num2 = mysql_numrows($result2);

    $posts = $posts + $num2;

    $query3 = "SELECT * FROM ".$fname."_users";
    $result3 = mysql_query($query3);
    $num3 = mysql_numrows($result3);

    $users = $users + $num3;

$i++;
}

echo "<b>Site Statistics: </b><br><br>
Forums: ".$i."<br>Users: ".$users."<br>Posts: ".$posts."";

?>

Hope it's what you need. :)
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,130
Members
1,603
Latest member
Monako
BETA

Latest Threads

Latest Posts

Top