Log in

View Full Version : Statistics


Blade-uk
10-16-2004, 05:09 PM
Right guys, nice easy one for ya im sure

At the bottom of vbulletin main page we have -

Threads: 209, Posts: 1,476, Members: 124

I want to show this information on my main site.

How do i go about this?

Cheers guys,

Andy

Dean C
10-16-2004, 06:52 PM
It's stored in the cache You want to do something like this:



$handle = mysql_connect('localhost', 'username', 'password');

$datastoretemp = mysql_query("
SELECT title, data
FROM databasename.datastore
WHERE title = 'forumcache'
OR title = 'userstats'
", $handle);

// initialise
$forumcache = array();

while ($storeitem = mysql_fetch_array($datastoretemp))
{
switch($storeitem['title'])
{
// get $forumcache array
case 'forumcache':
{
$forumcache = unserialize($storeitem['data']);
}

// stuff the data into the $datastore array
default:
{
$datastore["$storeitem[title]"] = $storeitem['data'];
}
break;
}
}

$totalthreads = 0;
$totalposts = 0;
if (is_array($forumcache))
{
foreach ($forumcache AS $forum)
{
$totalthreads += $forum['threadcount'];
$totalposts += $forum['replycount'];
}
}
$totalthreads = number_format($totalthreads);
$totalposts = number_format($totalposts);

// get total members and newest member from template
$userstats = unserialize($datastore['userstats']);
$numbermembers = number_format($userstats['numbermembers']);
$newusername = $userstats['newusername'];
$newuserid = $userstats['newuserid'];

echo "Total Threads: $totalthreads" . '<br />';
echo "Total Posts: $totalposts" . '<br />';
echo "Members: $numbermembers";



Replace databasename.vb3tablename.datastore with the relevant info.

Blade-uk
10-17-2004, 12:19 AM
Well, some parts worked, and some parts didn't.

What it says -

Total Threads: 0
Total Posts: 0
Members: 124

What it SHOULD say -

Total Threads: 209
Total Posts: 1,476
Members: 124

any ideas anyone ?

Blade-uk
10-17-2004, 10:23 AM
anyone :( been up all night trying to figure this out, and i suck at php :( lol

Blade-uk
10-17-2004, 12:47 PM
woo hoo, fixed now :D

http://www.tech-arena.co.uk/index.php

under community stats :D

Boots
01-27-2005, 03:08 PM
how did you fix it ?