Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Other Chat (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=12)
-   -   Small PHP Question (http://www.mysidiaadoptables.com/forum/showthread.php?t=417)

snowman01 02-19-2009 06:59 PM

Small PHP Question
 
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!".

BMR777 02-19-2009 07:03 PM

RE: Small PHP Question
 
Well, take a look at the script below I made a while ago. It outputs your site stats including forums, users, posts, etc. :)

PHP Code:

<?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. :)

snowman01 02-19-2009 07:06 PM

RE: Small PHP Question
 
Thanks! This is what I wanted. :)


All times are GMT -5. The time now is 06:27 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.