Hamtaro 0 Report post Posted February 1, 2005 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
LuciferStar 0 Report post Posted February 1, 2005 first of all,you have to design your structure of the database,add a timestamp to each record,like that,you can sort all the records by timestamp,then you can reverse the record. Share this post Link to post Share on other sites
bjrn 0 Report post Posted February 1, 2005 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
LuciferStar 0 Report post Posted February 1, 2005 To avoid getting the whole data from the database, try: SELECT * FROM chats ORDER BY date DESC limit 10 Share this post Link to post Share on other sites
Hamtaro 0 Report post Posted February 2, 2005 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