MyBB Community Forums

Full Version: Forum Stats..
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I was wonder if there was a MOD to show how many posts, how many users, and the newest user on a page that is not in the main forum directory (for my index.php page thats NOT in the forums directory)...

I really need this to work badly.

Thank you very much!
Not really, unless there is a way to show the stats on my MAIN PAGE (NOT THE FORUMS)..

Maybe you don't understand so here:

Okay, I want to show the stats in the index.php page of my site (NOT THE BOARDS), in the public_html folder... (NOT IN THE BOARDS!!!!). The stats will point to the boards and show some stats, again (NOT IN THE BOARDS!!!!!!!!!!!!!!!!!!!!!!!) the stats file will NOT be in the forum directory THAT MEANS NO WHERE NEAR!
Hey...

In the following code, we are creating a connection to the MyBB db. and we will retrieve the newest member, total members and total posts in a page outside mybb system.

This code will be added to you site's codes.

//Connect to mybb db
	mysql_connect("localhost", "username", "password") or die("Could not connect to MySQL");
	mysql_select_db("db_name") or die("Could not connect to MySQL");

	//Get total posts
	$query = mysql_query("SELECT COUNT(*) as total FROM mybb_posts");
	$get_total_posts = mysql_fetch_array($query);
	$totalposts = $get_total_posts['total'];

	//Get total users
	$query2 = mysql_query("SELECT COUNT(*) as total FROM mybb_users");
	$get_total_users = mysql_fetch_array($query2);
	$totalusers = $get_total_users['total'];

	//Get newest member
	$query3 = mysql_query("SELECT * FROM mybb_users ORDER BY regdate DESC LIMIT 0,1");
	$info = mysql_fetch_array($query3);
	$username = "<a href=\"member.php?action=profile&uid=".$info['uid']."\">".$info['username']."</a>";
	
	echo "Total posts is ".$totalposts;
	echo "<br />";
	echo "Total members is ".$totalusers;
	echo "<br />";
	echo "Newest member is ".$username;
Works perfectly, thank you very much.