PDA

View Full Version : Making Newest News Appear on Top With PHP/MySQL...



Niaad
March 17th, 2001, 20:49
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 :).

Gonzo
March 17th, 2001, 22:06
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.



SELECT * FROM table ORDER BY id DESC

Niaad
March 17th, 2001, 22:17
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

Eclipse
March 20th, 2001, 09:06
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.

Niaad
March 21st, 2001, 16:14
I know it doesn't stand for opposite, but it means the samething.

atlas
March 21st, 2001, 18:37
You can also write out 'ascending' and 'descending' instead of 'asc' and 'desc' respectively.

-mk