Hey Guys, I need some Help!!

Hey guys. I need some help in my site…
I made a site with User List , register , stuff, I think you know what I mean…
Anyways, I need a code to see the online Users . I mean, when someone is online, to show in userlist a green icon…and when he goes offline to show a red one…
Can anyone help me with that problem…
I need the codes, FULL CODES!! …
I tried in all my ways…nothing works, really nothing…
if you can make me a tutorial, I really need to do it into my site…(that will make my site better)
Here is my website

There’s no really easy way of doing that, but the simplest way that i know of doing it is to add a column to your users table called online. When the person logs in, update that column with a 1 or whatever you want. When they log out (assuming you don’t use cookies), then update it again.

To check to see how many users are online, then run a query and count the rows (mysql_num_rows()) returned.

Can you Help me somehow? or…do you have some friends to help me?

Anyways…
gimme your MSN if you are a pro PHP… I would like to ask you few questions…
add me : [email protected]

I’m no pro, i know enough to get by lol :). as an example:
[php]
//in your login script, after the login
mysql_query("UPDATE users SET online = 1 WHERE id = $r[‘id’]
[/php]

If you want the number of users online, then it would something like
[php]
$qry = mysql_query(“SELECT online FROM users WHERE online = 1”) or die(mysql_error());
$users_online = mysql_num_rows($qry);

echo $users_online;
[/php]

Then when they log off, you would run that same update script, changing the 1 to a 0.

There are far more elaborate scripts that deal with sessions and whatnot, but that’s beyond my abilities. Just remember that its not going to be all that accurate because most people just close the browser instead of logging off.

You could also add another column to record the session id, then query the server to see if the file exists (using file_exists()). if it doesn’t then run the update query.

look , better would be if you will gimme your msn, or add me… :D…
Okay, the on/off, you gave me a start…
but I would explain you more about that stuff… :smiley:
Please :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service