waynemac Posted August 12, 2004 Posted August 12, 2004 Hi all, hope ur having a great summer...or winter. Just wondering how to get options in drop down menu to list alphabetically rather than in the order they were input. I am pulling them out of sql. Thanx in advance. Wayne in Japan Quote
borfast Posted August 12, 2004 Posted August 12, 2004 (edited) Hi Wayne. HTML does not provide a way to sort those menu entries, it will always display them in the same order as they appear in the HTML code. Your only choice is to order those entries in the SQL query itself. Try something like this: SELECT * FROM table_name ORDER BY name ASC This will return the results sorted by the 'name' column, with ASCending order. If you want it to have descending order, use DESC instead of ASC Also, instead of 'name' you should use the column name that contains the menu entries' text that you want to be sorted. Hope that helps Edited August 12, 2004 by TCH-Raul Quote
waynemac Posted August 12, 2004 Author Posted August 12, 2004 Raul, thanks for that. Worked like a charm. Brilliant. Well, got the order on the SQL side to change but it didnt stick. But have found in the Operations tab the option to order by # or en. Done. Thanx. Wayne Quote
borfast Posted August 12, 2004 Posted August 12, 2004 (edited) I'm supposing you mean the Operations tab of phpMyAdmin, am I right? That does order things permanently on the table but only the rows that are already inserted. If you insert new rows, you'll have to do that again. If that's not a problem, for example, if you won't ever need to change the data in that table, then you're OK. But I think you should try to get that ORDER statement to work, just in case. Have you changed the name of the column you want it to order the results by? Edited August 12, 2004 by TCH-Raul Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.