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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.