Jump to content

Recommended Posts

Posted

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

Posted (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 :D

 

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 by TCH-Raul
Posted

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 :D

Posted (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. :D

Have you changed the name of the column you want it to order the results by?

Edited by TCH-Raul

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...