Kev0121 Posted April 19, 2009 Share Posted April 19, 2009 Well in my database in my users table i have a field called 'active' and when users are logged in it changes to 1. What im trying to do is write a sql statement that says check if the user id of $_SESSION['uid'] if their active field is set to 1, if so echo out "Online" if that makes sense? sorry lol didnt know how to describe. something like this... $sql = "SELECT active FROM users WHERE active = 1 AND id = ' " . $_SESSION['uid'] . " ' "; Thanks /Kev Link to comment https://forums.phpfreaks.com/topic/154787-stuck-on-sql-statement/ Share on other sites More sharing options...
Michdd Posted April 19, 2009 Share Posted April 19, 2009 $sql = "SELECT active FROM users WHERE active = 1 AND id = '{$_SESSION['uid']}' "; I think the query you were trying to write is something like that? Although, I don't see why you'd only want to select active.. Link to comment https://forums.phpfreaks.com/topic/154787-stuck-on-sql-statement/#findComment-813975 Share on other sites More sharing options...
Nazirul Posted April 19, 2009 Share Posted April 19, 2009 lol .. do u mean when a user log in, then the script will UPDATE the SQL in the column 'active' u can do such : once the correct id and password; if (mysql_num_rows($result) == 1) { //sql UPDATE here Link to comment https://forums.phpfreaks.com/topic/154787-stuck-on-sql-statement/#findComment-813981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.