Page 1 of 1

How to compare all dates in a specific field of a table....?

Posted: Sat Jun 23, 2007 5:39 am
by Malinga
So here's the deal...
I'm not an expert at PHP/MySQL, and just build websites for a hobby. Currently I'm building a news display on my front page, from which all details for each news entry will come from a MySQL database with the following fields:

newsid, newsdate, newstitle, newstext
14, 2007-06-23, Under Construction!, As you can see, the site is still under constructi...

that record is just one example to clarify...

Now, on my front page I need the most recent 3 articles to be displayed, whilst all the others can be found on a separate page (news archives)...
What coding can I use to compare all the dates from the table, and find which three articles are the most recent, in order to display only those on the front page?

All help is appreciated,
Thanks

Posted: Sat Jun 23, 2007 7:02 am
by superdezign

Code: Select all

SELECT `newstitle`, `newstext` FROM `newstable` ORDER BY `newsdate` DESC LIMIT 0,3;
ORDER BY is what you're after.

Posted: Sun Jun 24, 2007 3:26 am
by Malinga
Thanks ever so much super design
Your help is much appreciated