Fido Fido - 5 months ago 13x
SQL Question

Notify on page when a user comes online IN DOM

I have this for adding the users online status when they are enter on my page and is working fine but i want this, when the online status goes "ON" on a specific user i want the script send a plublic notification with css in left corner "The user X is online now". Any help apreciated!

i have this Php process for the moment:

$tm=date("Y-m-d H:i:s");
$q=mysql_query("UPDATE mls_users SET statusonline='ON',tm='$tm' WHERE id='$id'");
} else {
echo "no user online";
$gap=5; # <-time
$tm=date ("Y-m-d H:i:s", mktime (date("H"),date("i")-$gap,date("s"),date("m"),date("d"),date("Y")));
$ut=mysql_query("UPDATE mls_users SET statusonline='OFF' WHERE tm < '$tm'");


Update your code & add a variable:

From database you can find those users whose status is on line.

For public notification, (using ajax) you can check which users' status is"online='On'" & refresh the DOM element where you are showing the notification.