Jump to content

online or offline query


deepson2

Recommended Posts

Hello,

 

I want to show users status that weather he/she is online or not. so i have added one column last_access with type datetime

 

i am ding this because if without logged in user just closed his/her browser then,i wont be able to figure out whether he/she is online or not.

 

so using datatime, i can select user who is logged in last 15 minute.

but i am just no able to figure out what i am doing wrong here.

here is my query

 

$update = $op->runsql("UPDATE ".tbl_author." SET last_access = '".date('Y-m-d H:i:s')."' WHERE id = '$uid'");
  if(mysql_num_rows($update) > 0){

}
$result            = $op->runsql("SELECT TIMESTAMPDIFF(MINUTE, a.last_access, NOW()) >15 from
".tbl_author." as a where a.id ='$uid");
  if(mysql_num_rows($result) > 0){
echo "online";
}else{
  echo "offline";
  }

 

can anyone help me, how can i achive this?

thnaks in advance.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.