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
Displaying 1st Entry
Moderator: General Moderators
- iknownothing
- Forum Contributor
- Posts: 337
- Joined: Sun Dec 17, 2006 11:53 pm
- Location: Sunshine Coast, Australia
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Why not try something like:
edit: figured out what you meant and edited the post...
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));
Last edited by Kieran Huggins on Sun Feb 11, 2007 5:40 am, edited 2 times in total.
- iknownothing
- Forum Contributor
- Posts: 337
- Joined: Sun Dec 17, 2006 11:53 pm
- Location: Sunshine Coast, Australia
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- iknownothing
- Forum Contributor
- Posts: 337
- Joined: Sun Dec 17, 2006 11:53 pm
- Location: Sunshine Coast, Australia