Page 1 of 1

Displaying 1st Entry

Posted: Sun Feb 11, 2007 5:01 am
by iknownothing
Hey guys,
I have a page where a single database entry is shown by changing the value of a drop-down menu. How would I display the first alphabetically ordered entry in the database without having to submit the dropdown menu form? The ID (auto-increment) field may not always be 1 as entries can be deleted, so I'm thinking that I should bypass the dropdown at first load but not sure how to word the sql query to display first entry in alphabetical order only.

Thanks

Posted: Sun Feb 11, 2007 5:32 am
by Kieran Huggins
Why not try something like:

Code: Select all

$result = MySQL_query("SELECT * FROM `whatever` ORDER BY `something` DESC");

$row=mysql_fetch_assoc($result);

// show the first row's thing here

do{

   //build the drop down options here

} while ($row=mysql_fetch_assoc($result));
edit: figured out what you meant and edited the post...

Posted: Sun Feb 11, 2007 5:38 am
by iknownothing
no, i know how to order, and i know how display ALL entries, but I only want to display the very first alphabetical entry, eg AARDVARK.

Posted: Sun Feb 11, 2007 5:45 am
by Kieran Huggins
sorry - I was editing my post when you replied (I wish there was some ajax-powered new-post-notification in the edit window) - anyway, just wanted to "bump" the old thread.

You could also auto-select and submit the first entry with javascript.

Posted: Sun Feb 11, 2007 5:48 am
by iknownothing
I could have done that if my brain was on. Thanks.