hoponhiggo Posted July 3, 2011 Share Posted July 3, 2011 Hi guys I have some code which displays the profile picture the logged in user. <?php $dir = "prof_pics"; $sql = "SELECT prof_pic FROM users WHERE username = '{$_SESSION['MM_Username']}'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0) die("Username not found in database."); $row = mysql_fetch_array($res); echo "<img src='$dir/{$row['prof_pic']}' width='88' height='88' align= center><br>"; ?> What i want to do is adapt this to show the profile picture of all the currently 'online' users. Is there a session variable i could replcae the '{$_SESSION['MM_Username']}' with on the sql? Quote Link to comment https://forums.phpfreaks.com/topic/240986-change-code-to-display-session-user/ Share on other sites More sharing options...
freelance84 Posted July 3, 2011 Share Posted July 3, 2011 You would need to have some way of determining who was online... you could have an entry in the table users 'online' 1/0 where one is online and 0 is offline. Set the field when logging In and out. THen you just need a way of checking if the person is still online during their session encased they close the browser without pressing log out. Quote Link to comment https://forums.phpfreaks.com/topic/240986-change-code-to-display-session-user/#findComment-1237831 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.