• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Making Newest News Appear on Top With PHP/MySQL...

Niaad

New Member
I am writing a small news script for a site of mine that has a few games I have created.

I have figured out how to make it so it only displays news from the database if it is greater than the minimum date (basically today - 7), but I am having trouble ordering the news so that the newest news items appear on the top, rather than the bottom.

New news items have a higher ID, and they also have a higher date...the two principle ways of ordering news are therefore eliminated, because the ORDER BY command makes the lower numbers appear on the top (i.e. news with ID 1, which would be the first news item posted, will appear above news with ID 7...which doesn't make any sense because ID 7 would mean it was obviously posted after ID 1, and therefore should be above it.)

Here is where I am using it: http://www.niaad.com/nsprod/index.php

I am asking if there is anyway to make the ORDER BY command opposite, and or any other possible solutions.

Thanks in advance :).
 
You kinda lost me but I think I know what you was trying to say, I think you wanted to take the news out of the database and you want the highest ID at the top?

this should work.

Code:
SELECT * FROM table ORDER BY id DESC
 
Ah! Thank you, it works! I knew it would be something simple like that, I but I wasn't about to start guessing short forms of words that mean "opposite." :)

Thanks again! :D
 
He... it doesn't stad for "opposite". DESC = Descending, ASC = Ascending.

Please correct my spelling in case it's wrong, but 'DESC' and 'ASC' are the ones to use.
 
You can also write out 'ascending' and 'descending' instead of 'asc' and 'desc' respectively.

-mk
 
Back
Top