Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reversing Order

Status
Not open for further replies.

Cirvam

Programmer
Nov 23, 1999
58
US
I have a page that loads the news from a table. It works fine however the news is backwards. i.e. the oldest stuff is at the top (because it is in the database first I guess) and the newer stuff at the bottem...How can I reverse the order so that the new stuff is at the top?

Thanks

Erik
cirvam@netzero.net

Looking to learn more about Linux, Apache, PHP and others.
 
If you have a date column in your table, this is as easy as inserting an "ORDER BY [column]" in the SQL query (I'm pretty sure that's part of the ANSI standard).

Otherwise, when pulling your results, stick each one in an array (let's say $news[]) and move through it by popping. eg.

while(count($news) > 0) {
echo array_pop($news);
}

brendanc@icehouse.net
 
thanks that worked well except I had to add "DESC" to make it decend :)

Thanks

Erik
cirvam@netzero.net

Looking to learn more about Linux, Apache, PHP and others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top