/    Sign up×
Community /Pin to ProfileBookmark

Help with showing who is online

I want to know how to show my users that are online, If you have a better way or a way of making this work please post your ideas here. Okay so would someone either make me a script so I can learn, but here is what i am thinking of how making it work. Say I have a user login so they are using sessions then i have a field in my mysql database in a table called members and it inserts a timestamp as in it changes the timestamp ex. when I log in it will take a timestamp and store it in db as online and when I go to another page it does it again basically and changes it to the time i went to that page.

Then i will have a USERS ONLINE thing at bottom of all pages and it caculates and shows the users that have basically been “active” in the last 3 or five minutes dont care, but basically I just want to create something that shows which members are online

Please help create this code as in basically showing how to caculate the 3 or 5 minute difference and then show them on the USERS ONLINE

the 3 or 5 minutes is i am saying either use 3 or 5 b/c that is reasonable to be pretty accurate.

Well if you have a way of doing this different then I have prescribed then plz post or can you show me how to do what I prescribed.

Thanks adeang

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@holidayMar 22.2008 — [code=php]<?php
//set number of minutes
$num_min = 5;

//get TS
$time_stamp = time()-(60*$num_min);

//do mysql query
$result = mysql_query("SELECT * FROM members WHERE last_active>$time_stamp");

echo "USERS ONLINE<br /><br />";

while($row = mysql_fetch_array($result)) {
echo $row['username'] . "<br />";
}
?>[/code]
Copy linkTweet thisAlerts:
@adeang_1authorMar 22.2008 — thanks for quick reply i will try this really quick
Copy linkTweet thisAlerts:
@adeang_1authorMar 22.2008 — THanks man my problem is solved
Copy linkTweet thisAlerts:
@holidayMar 22.2008 — any time
×

Success!

Help @adeang_1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...