CincoPistolero Posted January 22, 2009 Share Posted January 22, 2009 Hi all, I have numbered data over ten rows in the database. When I pull the data out via a select statement, I want to be able to choose how it is ordered in a dropdown box. I don't want the order by id ASC, and I don't want it to order numerically because that makes it wrong. And I don't want it alphabetically. Below are examples of the output of two different dropdowns. My question, is there a magical way to choose the order of things after entering data in the db, or do I have to add and extra field to the table like sortOrder. Examples of output 10 inches 12 inches 20 inches 8 inches I'd want the 8 at the top since it is the smallest size ------ Mahogany Birch Laquer Satin Maple (Standard) I'd want the Maple up top because it is the standard Thanks for any help, currently I just do a select * from table order by ID ASC Link to comment https://forums.phpfreaks.com/topic/141894-how-to-sort-properly/ Share on other sites More sharing options...
Lodius2000 Posted January 22, 2009 Share Posted January 22, 2009 make 8 08 Link to comment https://forums.phpfreaks.com/topic/141894-how-to-sort-properly/#findComment-742972 Share on other sites More sharing options...
chronister Posted January 22, 2009 Share Posted January 22, 2009 I may be wrong, but if ORDER BY XXX ASC does not get you what you want, then I think your best bet would be to add a field in the DB to sort by. You may place the numbers in there as 10, 20, 30, 40, 50 etc... which would allow you to place items in between if you added new item later. Nate Link to comment https://forums.phpfreaks.com/topic/141894-how-to-sort-properly/#findComment-742973 Share on other sites More sharing options...
haku Posted January 22, 2009 Share Posted January 22, 2009 Lodius had the right idea. If the number is saved in a text field, it needs to have a zero for it in order to be able to be displayed in numerical order. If the number can be saved in a different column - one set to int - then the leading zero isn't necessary. Link to comment https://forums.phpfreaks.com/topic/141894-how-to-sort-properly/#findComment-742979 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.