I have two tables:
people -> id, username, email, image
messages -> id, message, read_flag, recipient_id
My site can send messages but now I am trying to make an inbox to display them for each user.
This is my inner join to display messages ($id is the id of the user currently logged in):
"SELECT u.username, u.id, m.message
FROM messages m
INNER JOIN people u ON u.id = m.recipient_id
WHERE m.id = $id"
Can someone please tell me why there is no message displayed when I use this code:
<?php
$id = $_SESSION['SESS_MEMBER_ID'];
$result = mysql_query("SELECT u.username, u.id, m.message
FROM messages m
INNER JOIN people u ON u.id = m.recipient_id
WHERE m.id = $id");
//echo "<textarea>";
//echo "</textarea>";
while($row = mysql_fetch_array($result))
{
$message = $row['message'];
echo $message;
}
?>