Hello,
I am trying to create a web message features. This is the code that I have done so far:
messages.php
<?php
//LOAD INBOX MESSAGES
$result = mysql_query("SELECT * FROM messages WHERE to_stu_username='".$_SESSION['username']."' ORDER BY date") or die(mysql_error());
?>
<table id="admintable" border="1" cellpadding="2" cellspacing="0" width="900px">
<tr>
<b>Inbox</b><br><br>
<th>From</th><th style="width:500px;">Messages</th><th>Date</th>
</tr>
<?php
$i=0;
while ($data = mysql_fetch_array($result)){
$result2=($i%2)?'#DFA09D':'white';
echo "<tr bgcolor='$result2'>";
echo '<td>'.$data['from_stu_username'].'</td>';
echo '<td>'.$data['messages'].'</td>';
echo '<td>'.$data['date'].'</td>';
echo '</tr>';
$i++;
}
?>
</table>
<?php
//LOAD OUTBOX MESSAGES
$result = mysql_query("SELECT * FROM messages WHERE from_stu_username='".$_SESSION['username']."' ORDER BY date") or die(mysql_error());
?>
<table id="admintable" border="1" cellpadding="2" cellspacing="0" width="900px">
<tr>
<br><br><b>Sent</b><br><br>
<th>To</th><th style="width:500px;">Messages</th><th>Date</th>
</tr>
<?php
$i=0;
while ($data = mysql_fetch_array($result)){
$result2=($i%2)?'#DFA09D':'white';
echo "<tr bgcolor='$result2'>";
echo '<td>'.$data['to_stu_username'].'</td>';
echo '<td>'.$data['messages'].'</td>';
echo '<td>'.$data['date'].'</td>';
echo '</tr>';
$i++;
}
?>
</table>
One thing that I am trying to do right now is to create differentiation between new messages (unread) and old ones (read). How to do so? New messages should appears in bold font for example and the old ones in normal font color.
Any idea?