Jump to content

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/240986-change-code-to-display-session-user/
Share on other sites

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.

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.