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
https://forums.phpfreaks.com/topic/159075-online-or-offline-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.