Jump to content
xisto Community
Hamtaro

Reversing The Order Of Items In A Database How do you do it?

Recommended Posts

I have a chat PHP script, that I need a little help with. I'm wanting to use PHP/MySQL so that it will show the most recent message first. What it's doing, is showing the oldest message first, and newest message last. Is there something I can do to reverse the order of the messages? Thanks.(I know...I've had to ask for PHP help often, but I can't quite get a PHP book right now...sorry)

Share this post


Link to post
Share on other sites

Well, the easiet fix would be to edit the query that gets the data from the database. Yo don't have to edit the database itself at all.If you have something likeSELECT * FROM chatsyou should have SELECT * FROM chats ORDER BY date DESCEdit the table and field names to fit your database. I always get confused when sorting date fields, but I think DESC does newest to oldest, but if it still shows oldest first, replace DESC with ASC.

Share this post


Link to post
Share on other sites

Thanks a lot! That really helped! I had no idea that reversing the order was so si,mple! Also, thanks for showing me how to limit the data received from the dababase. That helped me out a lot!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.