user2571547
user2571547

Reputation: 87

Not displaying "sent" message

I am working on a simple inbox/pm system, and I can't figure out why but I can get the display working for sent messages, I can display the list of sent items, view pms from the inbox, but not sure what I am doing wrong, any tips appreciated..

here is my code:

<table>
<?php
$id = $_GET['id'];
$from_user = $_SESSION['user_id'];
$sql = "SELECT users.user_id, users.username, users.profile, messages.id, messages.to_user, messages.from_user, 
        messages.subject, messages.message, messages.has_read, messages.deleted, messages.date_sent
        FROM `messages`
        JOIN `users` ON messages.to_user = users.user_id 
        WHERE messages.from_user = '$from_user' AND messages.id = '$id' ORDER BY messages.date_sent DESC";
$result = mysql_query($sql);
$rows = mysql_fetch_array($result);
$from_user = $rows['from_user'];
$subject = $rows['subject'];
?><tr>
<td width="50px" align="center">
<img src="<?php echo $rows['profile']; ?>" width="40px"><br><?php echo $rows['username']; ?>
</td>
<td valign="top" width="350px">
<b><?php echo $rows['subject']; ?></b><br>
<?php echo $rows['message']; ?>
</td><td><?php echo $rows['date_sent']; ?></td>
</tr>
<tr>
<td colspan="3"><hr></td>
</tr>
</table>

Upvotes: 0

Views: 60

Answers (1)

user2542256
user2542256

Reputation: 138

Your have $from_user specified twice, try removing the second and see how you go.

Upvotes: 1

Related Questions