|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Alphabetizing dropdown list
I have this dropdown list as part of a form that inserts/updates to the MySQL database:
http://www.npiflorida.com/admin/cha...own2-member.php I'm trying to alphabetize the list and have a selected one showing first, here is the code I'm using. Would I have to retrieve the list into and array to sort it?: PHP Code:
|
|
#2
|
||||
|
||||
|
|
|
#4
|
|||
|
|||
|
OK, that was easy, thanks.
Also as mentioned but was probably not clear is the need to have a currently selected chapter displayed. HEre's the page tha this is part of: http://www.npiflorida.com/admin/update_member.php THis is the last page that they come to to update a member's data. It normally displays all their data from the database including the chapter. Need their current chapter to show in the field, but have the ability to select one if the member is changing chapters. |
|
#5
|
|||
|
|||
|
ok, nevermind. Figured it out. Thank you so much for your help.
|
|
#6
|
|||
|
|||
|
Oops. Spoke too soon. Have another Pulldown issue to resolve.
http://www.npiflorida.com/admin/cou...chapter_add.php Need to eliminate duplicate returns in result. Attempting as you see to use DISTINCTROW, have tried that and DISTINCT. What am I doing wrong? Using this code: PHP Code:
|
|
#7
|
|||
|
|||
|
try
Code:
SELECT DISTINCT county FROM tbl_chapter ORDER BY county a few other notes: don't use * unless it makes life a lot easier - i.e. if you want 7 or 8 fields from 10 that are there, use *. if you just want one or two, call them directly. okay, so this effect is minor in most cases, but when you are joining several large tables and there's a fair bit of output it'd be wise to minimise it. you might want to be a bit more consistent with your SQL case - so that it is obvious what is SQL and what are table names etc. good luck.
__________________
Little more than a playground for the bugs that live beneath us... |
|
#8
|
|||
|
|||
|
Thank you. Much appreciated.
Yes I agree, there are a lot of inconisistencies in my coding format which I need to clean up. Have other areas of this application needing tidying up as well. |
|
#9
|
||||
|
||||
|
You can also get rid of that empty if statement, unless you are going to use it in the future.
PHP Code:
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > Alphabetizing dropdown list |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|