I started a
thread which I wanted to extract the amount of total members on the forum. This has worked wonderfully but I am now looking for a way to extract the amount of users online from the database.
I am currently using a PHP script to call up the database and retrieve the information. However I am not familliar with the table I should be using, I'm currently using the vb_session table but it is giving me a wrong number for online users.
My goal is to get the amount of users online (members and guests) on the forum. But this is going to be called from another PHP page not related to the forum.
Code:
<?php
mysql_connect('localhost', 'thedogtr_stats', 'stats911');
mysql_select_db('thedogtr_amember');
$r = mysql_query('select count(*) from vbulletin_user');
$r = mysql_fetch_array($r);
$registeredusercount = $r[0];
$r2 = mysql_query('select count(*) from vbulletin_session');
$r2 = mysql_fetch_array($r2);
$onlineusercount = $r2[0];
echo $registeredusercount[0] . ',' . $registeredusercount[1] . $registeredusercount[2] . $registeredusercount[3] . ' Registered Members<br>';
echo $onlineusercount . ' Users Online <u>Now</u>';
?>
Any help would be greatly appreciated!! Thank you!