Ads Posted December 27, 2007 Share Posted December 27, 2007 I am trying to make an .php page that shows the members that are currently online, But i really have no idea how to make this, Well i had a few ideas But they all suck . So if anyone can help me Quote Link to comment https://forums.phpfreaks.com/topic/83304-online-members/ Share on other sites More sharing options...
pocobueno1388 Posted December 27, 2007 Share Posted December 27, 2007 1) Make a datetime field in your users table called something along the lines of "last_active" 2) On your header page (so it is called on every click) put an update query that will put the current date/time in the last_active field (this can be done using NOW()). 3) Your query to pull the users who have been active within the last 5 minutes will look something like this: SELECT username FROM users WHERE last_active > (NOW() - INTERVAL 5 MINUTE) Quote Link to comment https://forums.phpfreaks.com/topic/83304-online-members/#findComment-423845 Share on other sites More sharing options...
Northern Flame Posted December 27, 2007 Share Posted December 27, 2007 heres a function that someone previously created that works fine http://www.phpfreaks.com/forums/index.php/topic,171853.0.html Quote Link to comment https://forums.phpfreaks.com/topic/83304-online-members/#findComment-423849 Share on other sites More sharing options...
pocobueno1388 Posted December 27, 2007 Share Posted December 27, 2007 heres a function that someone previously created that works fine http://www.phpfreaks.com/forums/index.php/topic,171853.0.html This code will count every user that is online, including "guests". I'm assuming from the OP using the word "member" they are wanting logged in users only. Quote Link to comment https://forums.phpfreaks.com/topic/83304-online-members/#findComment-423852 Share on other sites More sharing options...
Ads Posted December 27, 2007 Author Share Posted December 27, 2007 I would like it to Display The Number of Users online, and also there Usernames and such. Quote Link to comment https://forums.phpfreaks.com/topic/83304-online-members/#findComment-423853 Share on other sites More sharing options...
pocobueno1388 Posted December 27, 2007 Share Posted December 27, 2007 Okay, so you are wanting ONLY logged in members. Give the method I supplied above a shot, post if you have any problems implementing it. Quote Link to comment https://forums.phpfreaks.com/topic/83304-online-members/#findComment-423855 Share on other sites More sharing options...
Ads Posted December 27, 2007 Author Share Posted December 27, 2007 Okay, so you are wanting ONLY logged in members. Give the method I supplied above a shot, post if you have any problems implementing it. How do you use the NOW() Function, i have never used it before :S Quote Link to comment https://forums.phpfreaks.com/topic/83304-online-members/#findComment-423860 Share on other sites More sharing options...
pocobueno1388 Posted December 27, 2007 Share Posted December 27, 2007 How do you use the NOW() Function, i have never used it before :S UPDATE users SET last_active=NOW() WHERE userID='$id' Quote Link to comment https://forums.phpfreaks.com/topic/83304-online-members/#findComment-424075 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.