Order Private Messages by top/latest bottom/earliest?
Posted: Tue Aug 26, 2008 12:50 pm
Please forgive me (and feel free to move the thread to the Database section if applicable) though I'm trying to figure out how to order messages in the private message system I've setup by date. By default I want to display the newest messages at the top and going down the list to earlier messages. I figure this may be a PHP issue to scan the $row['date_0'] (which is the sent date where as date_1 is the read date) though I'm not familiar enough to presume that I could not somehow do this with MySQL.
Since it's a message system the $row is defined inside of the while loop. I'm not looking for a direct answer though it would be nice. I'm actually having difficulty with the MySQL documentation. I eventually got used to W3C's and after a redesign can now figure out Apache. So I'm much more interested in learning how to independently research the topic so I can at least make more of an educated guess versus an empty handed sort of question. Here is the minimal though most applicable code I think is relevant to achieving this goal...
Since it's a message system the $row is defined inside of the while loop. I'm not looking for a direct answer though it would be nice. I'm actually having difficulty with the MySQL documentation. I eventually got used to W3C's and after a redesign can now figure out Apache. So I'm much more interested in learning how to independently research the topic so I can at least make more of an educated guess versus an empty handed sort of question. Here is the minimal though most applicable code I think is relevant to achieving this goal...
Code: Select all
if (!isset($_GET['folder'])) {$result1 = mysql_query("SELECT id, id_from, date_0, date_1, message, subject FROM `public_private_messages` WHERE id_for = '".$_SESSION['member']."' OR id_for_folder = 'New'");} // AND id_for_folder = 'Read'
if (!$result1) {$_SESSION['error'] = mysql_error(); header("location:messages.php?error");}
while($row = mysql_fetch_array($result1))
{
echo '<tr id="message_'.$row['id'].'"><td><input class="checkbox" type="checkbox" value="" /></td>'."\n";
echo '<td>'.$row['id_from'].'</td>'."\n";
echo '<td>'.$row['date_0'].'</td>'."\n";
echo '<td><a href="messages.php?message='.$row['id'].'">'.$row['subject'].'</a></td></tr>'."\n";
}