help displaying a pic
Hi Guys
Can anybody please help me with the following?
I have some code already in place which allows a logged in user to post a message. This message is then displayed on the page and also sent to a messgages table in a database along with the userid of the logged in user.
Currently, the profile picture of the logged in user is also displayed using:
<?php
//to display image from source
$dir = "profpics";
$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='38' height='38'><br>";
?>
Is there anyway the "SELECT prof_pic FROM users WHERE username = '{$_SESSION['MM_Username']}'"; part can be edited to display the profile pic of the person who left the message?
I would imagine it would be something along the lines of:
"SELECT prof_pic FROM users WHERE message.id = userid?