garevn Posted December 24, 2012 Share Posted December 24, 2012 Lets say i have 10 users in my database.I want to display 2 dynamic tables, one with the names from online users and one with the names from offline one..Any suggestion i am a bit confused Link to comment Share on other sites More sharing options...
satishpoul Posted December 24, 2012 Share Posted December 24, 2012 i think according to me you just add one more column to your database as status . when your user process for login.. after successful login just update status as a online otherwise default was offline (you can use true/false or 1/0) or copy logged in users data to your new table where you want to store logged in users and same for offline users. Link to comment Share on other sites More sharing options...
garevn Posted December 24, 2012 Author Share Posted December 24, 2012 ok it seems like the easyest way, but how i update the table after the log in... i tried to update and log in with the same form but its not possible...! Link to comment Share on other sites More sharing options...
thescientist Posted December 25, 2012 Share Posted December 25, 2012 (edited) i don't think you really have to do much, other than add a last_logged_in column to each user in your user table. Basically, everytime a user successfully logins, update the timestamp in the user table with the timestamp of that particular users login time. Your currently logged in users could be all users who's last_logged_in time falls within a specified criteria, i..e the past 15 minutes, 30 minutes, 1 hour, etc.http://www.w3schools.../sql_update.asp Edited December 25, 2012 by thescientist Link to comment Share on other sites More sharing options...
Ingolme Posted December 26, 2012 Share Posted December 26, 2012 Rather than last_logged_in I'd have a last_activity field. Anytime the user loads a page this timestamp is updated. To find out which users are online, check the difference between now and that date. $now = time(); SELECT username FROM users WHERE ($now - last_activity) < 900 900 means 15 minutes, 900 seconds. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now