CBaZ Posted July 24, 2007 Share Posted July 24, 2007 $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. Quote Link to comment Share on other sites More sharing options...
tomfmason Posted July 24, 2007 Share Posted July 24, 2007 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`"); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.