gaza165 Posted April 13, 2009 Share Posted April 13, 2009 I am trying to write a function that allows me to display whether a user is online, offline or idle.. this is what i have so far.... <?php include("dbconnect.php"); $sql = mysql_query("SELECT * FROM users WHERE TIMESTAMPDIFF(MINUTE,last_activity, CURRENT_TIMESTAMP()) < 5"); $query = mysql_query("SELECT * FROM users WHERE TIMESTAMPDIFF(MINUTE,last_activity, CURRENT_TIMESTAMP()) > 5"); $numrows = mysql_num_rows($sql); echo "<h4>".$numrows." users online</h4>"; echo "<ul class='online'>"; while($row = mysql_fetch_array($sql)) { echo "<li>"; echo $row['username']; echo "</li>"; } echo "</ul>"; ?> Can you help me a little further please!!! BTW I have this page set to run every 4 seconds to keep it constantly updating users statuses! Thanks Link to comment https://forums.phpfreaks.com/topic/153902-need-help-with-onlineidleoffline/ Share on other sites More sharing options...
revraz Posted April 13, 2009 Share Posted April 13, 2009 Help you further how? You don't say if there is a problem, if there is a error, if it works, if it doesn't work... Also, why would you need this to run every 4 seconds? Just have it run whenever that page you want the status displayed on to accessed. And finally, what is "Idle"? You won't need that. Can you help me a little further please!!! BTW I have this page set to run every 4 seconds to keep it constantly updating users statuses! Thanks Link to comment https://forums.phpfreaks.com/topic/153902-need-help-with-onlineidleoffline/#findComment-808905 Share on other sites More sharing options...
gaza165 Posted April 13, 2009 Author Share Posted April 13, 2009 Well I am using jquery, so no refreshes or posts are being made to the page, it is one static page. $sql = mysql_query("SELECT * FROM users WHERE TIMESTAMPDIFF(MINUTE,last_activity, CURRENT_TIMESTAMP()) < 5"); //This checks to see if a user is still online... $query = mysql_query("SELECT * FROM users WHERE TIMESTAMPDIFF(MINUTE,last_activity, CURRENT_TIMESTAMP()) > 5"); //Then after 5 mins of inactivity I would like it to change the status to idle. Then, finally get it to remove the user from the list to show they are offline!! sort of like a timeout Link to comment https://forums.phpfreaks.com/topic/153902-need-help-with-onlineidleoffline/#findComment-808910 Share on other sites More sharing options...
gaza165 Posted April 13, 2009 Author Share Posted April 13, 2009 I really need help with how to display the status out!! Link to comment https://forums.phpfreaks.com/topic/153902-need-help-with-onlineidleoffline/#findComment-808918 Share on other sites More sharing options...
gaza165 Posted April 13, 2009 Author Share Posted April 13, 2009 somone help me!! Link to comment https://forums.phpfreaks.com/topic/153902-need-help-with-onlineidleoffline/#findComment-808934 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.