Jump to content

user online issue


CBaZ

Recommended Posts

$timeMax = time() - (60* SESSION_LENGTH);

 

$result = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax' and permission ='0'");

$usersOnline = mysql_result($result, 0, 0);

 

$resulta = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax' and permission = '1'");

$usersOnline2 = mysql_result($resulta, 0, 0);

 

ok there has to be a way to set a limit .. the numbers just go through the roof. go beyond as many users there can possibly be online is there a way to put a limit in there somehow. the rest of my code is like this. where i get how many total users there are.

 

$result3 = mysql_query("SELECT COUNT(*) AS count FROM users WHERE permission = '0'");

$row = mysql_fetch_array($result3);

 

$result4 = mysql_query("SELECT COUNT(*) AS count FROM users WHERE permission = '1'");

$row2 = mysql_fetch_array($result4);

 

echo "ATM:" . ($usersOnline2 != 1 ? "" : "") . " $usersOnline2 Admin" . ($usersOnline2 != 1 ? "s" : "") ." / $row2[count]" . ", " . ($usersOnline != 1 ? "" : "") . " $usersOnline User" . ($usersOnline != 1 ? "s" : "") ." / $row[count]" . ". ";

 

the bottom code gives away the total admins and regulars on my system.  now i am trying to limit the above code to those numbers so only up to 2 admins and users remain.

Link to comment
https://forums.phpfreaks.com/topic/61602-user-online-issue/
Share on other sites

I would group by the ip address. When you record the hit from the user make sure that you are storing their ip address. Then you can modify your query to something like this.

 

<?php
$result = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax' and permission ='0' GROUP BY `ip_address_field`");
?>

Link to comment
https://forums.phpfreaks.com/topic/61602-user-online-issue/#findComment-306632
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.