Order by question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Order by question

Post by Addos »

Hi,
I have a page http://www.jlp.ie/future_events.php and when the page loads the information on the right-hand side is taken from the first entry in the database where I want it to be the last or latest entry in the database. Normally I know this is done by adding Order by ASC/DESC etc but as the information on the right is queried by the links on the left of the page by the following.

Code: Select all

$query_GetNewsDetails = sprintf("SELECT * FROM future_events WHERE id = %s ", $colname_GetNewsDetails);
So my problem is that I can’t add WHERE id = %s ORDER by ASC as this obviously doesn’t work so can anyone advise me as to how I can get the page to initially load with the details on the right showing the most recent information that is added to the database.
Thank you very much
Brian
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Rather than looping through a Record Set, perhaps you could just load all of the results into an array. Then you could display the list at the left by looping through the array, and display array[0] on the right.
(#10850)
Post Reply