ki Posted December 21, 2006 Share Posted December 21, 2006 ok, I already got the users online script, but I want to show the users that are online like, "ki, user, die", like that I got the usernames too Quote Link to comment Share on other sites More sharing options...
trq Posted December 21, 2006 Share Posted December 21, 2006 When users login you would need to store there usernames along with a timestamp in a table in the database, for each page hit you would need to update the timestamp.You then need another script that would clear out older entries. Quote Link to comment Share on other sites More sharing options...
ki Posted December 21, 2006 Author Share Posted December 21, 2006 yea i got that script, but i need it to display the users like on a regular forum likeUsers online:ki, user, user2 Quote Link to comment Share on other sites More sharing options...
trq Posted December 21, 2006 Share Posted December 21, 2006 I understood your question, read my answer. Quote Link to comment Share on other sites More sharing options...
JP128 Posted December 21, 2006 Share Posted December 21, 2006 when I got helped, It only showed that some users were online... but then I modified it so it showed each one...here is the scriptmake sure your users table has a column named online...ALTER TABLE `tablename` ADD online TIMESTAMP;Have this in another page called showusers.php[code]<?phpsession_start();//Connect to the databaseif (isset($_SESSION['username'])) { // checking to see if there is a user logged in// user logged in so update current time in 'online' column of 'user' table$query = "UPDATE users SET online = now() WHERE username = \"".$_SESSION['username']."\"";$result = mysql_query($query);}$query = "SELECT username,online FROM users WHERE now() - online<=500";$result = mysql_query($query);echo "Users online: ";while ($row = mysql_fetch_assoc($result)){if($row['diff'] < 500) {// user has been online within the last 5 minutesecho $row['username'] . " ";}}?>[/code]After you modify the script to work the way you need... put this on pages that you want to show who is online:include "showusers.php";if you have any questions, just reply or send me a PM Quote Link to comment Share on other sites More sharing options...
ki Posted December 21, 2006 Author Share Posted December 21, 2006 thats kinda what im looking for, but with commas but it doesnt end with one likeki, user, user2,but i want it like how it shows the users viewing the current page like, Users Viewing Forum: ki, user, user2 Quote Link to comment Share on other sites More sharing options...
trq Posted December 21, 2006 Share Posted December 21, 2006 Were not here to write if for you. A few people have explained how it is done, now go and make it. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 21, 2006 Share Posted December 21, 2006 thats what this forum is for, help... not people making scripts. people here give you a push in the right direction, its up to you to follow that direction... Quote Link to comment Share on other sites More sharing options...
JP128 Posted December 21, 2006 Share Posted December 21, 2006 Here... If you make another column called current_page... make it a varchar(50)...then on all of the pages include a script that updates the current_page to $_SERVER['PHP_SELF']... after it 'SETS' that value, then select all of the users that have the current_page to = $_SERVER['PHP_SELF']... and if it equals echo their username...if that isnt hint enough, I dont know what is. 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.