Page 1 of 1

News script, but posts are "out of order"?

Posted: Fri May 09, 2003 10:36 pm
by scr0p
When someone posts, It seems like the post gets put at a random location within the database, I have these files: Nick, Email, Topic, Body, and ID (auto increment).

I want the newest post to be on top on my php page, how can I do this?

Right now I am added 3 fields, IP, Date, and Icon, (will hold a URL to a little icon for each user that posts). I want the user to be able to sort by date or by nick..etc but ill save that question for later on after I get the newest post on top :D

Posted: Sat May 10, 2003 11:40 am
by twigletmac
You just need to add an ORDER BY statement to the end of the SELECT query:
http://www.mysql.com/doc/en/SELECT.html

Code: Select all

SELECT field1, field2, field3 FROM table ORDER BY field1
Mac