Reversing Displayed results from a table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mikes1471
Forum Commoner
Posts: 88
Joined: Sat Jan 24, 2009 3:29 pm

Reversing Displayed results from a table

Post by mikes1471 »

Hey everyone

I've just designed the 'inbox' for my online users to carry out peer to peer messaging through my website and all is working OK, displaying results in a table of the message date, message sender and message subject but typically the newest message is displayed on the bottom row, how can I change this so the more recent messages are at the top?
User avatar
vargadanis
Forum Contributor
Posts: 158
Joined: Sun Jun 01, 2008 3:48 am
Contact:

Re: Reversing Displayed results from a table

Post by vargadanis »

Hi,
you need to order the mysql results. I suppose you have something like ID or sent date stored in the table. Try something like:

Code: Select all

$rec = mysql_query("SELECT * FROM `table` ORDER BY `sentData` DESC");
This will put the newest on top.

Regards! :)
mikes1471
Forum Commoner
Posts: 88
Joined: Sat Jan 24, 2009 3:29 pm

Re: Reversing Displayed results from a table

Post by mikes1471 »

Excellent thankyou!
Post Reply