To be up front, I'm new to PHP/SQL programming. I've probably coded this wrong, or "the long way". To be honest, I don't know the difference. I'm just trying to make a basic web-chat room for a fun project. Currently, the messages that are displayed in the room are sorted by the timestamp in descending order. The newest messages are displayed on the top of the page. What I would like is to have the newest messages at the bottom of the page. I'm only displaying 30 messages at a time. I cannot figure out how to "flip" the messages so that the newest shows up at the bottom. (I hope this makes sense). Here's what I've been using to display the messages:
$query = "SELECT * FROM roomdata ORDER BY timestamp DESC LIMIT 30 ";
$result = mysql_query($query);
if ($result) {
while($row= mysql_fetch_array($result)) {
// Check to see if the message was sent by a chatter
if ($row['sender']){
$publicmessage= '<b>['.$row['sender'].']</b> '.$row['message'];
}else{
// if not, it must have been sent by the server (ie: login message, server announcement, etc)
$publicmessage= $row['message'];
}
echo "$publicmessage <BR>";
}
}
Can anyone point me in the right direction?
If I've not included enough information, I apologize - I'm new to all of this. Thank you in advance for your time!