PDA

View Full Version : Number of Reg. Members Online on non-vB page?


RobAC
07-11-2001, 02:16 AM
How can I modify the following code to show the number of registered members online (like the number of guests online) instead of listing the member names? If possible, I'd also like to show the total number of registered members with the forums?


<?php
require("admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);

$cookievalue = mysql_query("SELECT value FROM setting WHERE varname = 'cookietimeout'") or die("oops1");
$cookietimeout = mysql_result($cookievalue, 0, 0);
$datecut = time()-$cookietimeout;
$invisibleregmember = "0";
$regmembers = mysql_query("SELECT DISTINCT username,invisible FROM user,session WHERE session.userid=user.userid AND session.lastactivity>$datecut AND invisible='0' ORDER BY username ASC") or die("oops2");

while($regmember = mysql_fetch_array($regmembers)):

++$regmembercomma;
if ($regmember[invisible] == 0) {
$regmemberson .= $regmember[username];
} else {
++$regmembercomma;
}
if ($regmembercomma < mysql_num_rows($regmembers)):
$regmemberson .= ", ";
endif;
endwhile;

$guests = mysql_query("SELECT COUNT(userid) AS guestsonline FROM session WHERE userid=0 AND session.lastactivity>$datecut") or die("oops3");
while($guest = mysql_fetch_array($guests)):
$guestson = number_format($guest[guestsonline]);
endwhile;

print("<b>Members:</b></font>&nbsp; <font class='verdana, arial, helvetica' color='#330099'>$regmemberson</font><br />");
print('<font class="verdana, arial, helvetica">');
print("<b>Guests:</b></font>&nbsp; <font class='verdana, arial, helvetica' color='#330099'>$guestson</font>");

?>

RobAC
07-14-2001, 05:38 PM
^^^^^^bump^^^^^^^^^^