MyBB Community Forums

Full Version: show the stats in the entire page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi
i need a code that show that show the forum stats in other page for example if our forum url is http://mysite.com/forum/
and we want to show the sta in http://mysite.com/index.php
what code should i put in that page...
Which stats do you mean?
You can load almost everything if you add
require "forum/global.php";
at the top of your page and use some MySQL queries. You don't actually have to add global.php, but it's just easier that way. Then you can use $db->query("SELECT * FROM ".TABLE_PREFIX."users ... -type queries and you don't have to connect to your DB anymore..
sorry but i mean if i want to show thAT satas in an extenal page what should i do?
you mean that if i include("forum/global"); i can see the stats but how?
coulde you guide me better? plz
bluedream3964 Wrote:sorry but i mean if i want to show thAT satas in an extenal page what should i do?
you mean that if i include("forum/global"); i can see the stats but how?
coulde you guide me better? plz

When you have included that line in the page you want, just add something similar like this:
(in this example I'll use the 5 latest registered users stats)
$query = $db->query("SELECT username FROM ".TABLE_PREFIX."users ORDER BY regdate DESC LIMIT 0,5");
echo "<b>5 Latest users:</b><br />";
while($user = $db->fetch_array($query))
{
echo "* ".$user['username'];
echo "<br />";
}
This will output something similar like:
Quote:5 Latest users:
* John
* Martisha
* Eric
* Smethead
* MisterX

For more info on writing queries, you can go here: http://www.php-mysql-tutorial.com/mysql-.../index.php