I know how to create a drop down list, however if you had to create a form where one of the input is a state (a two letter word) in a drop down list, do I just input the state one by one or should I store the state in a DB?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is kinda weird question. Depending on your project of course.
If you need performance and speed, when loading your dropdown list (I’m assuming you meant
<select />). Then you might want to put them into a separate.phpfile in an array form. So later on you could just loop them withforeach(). This method will surely load faster, then to load 50 states from DB.inc-states.php:
Generate form:
So after posting you will only save the keys. Later on you can again get the right state via the key:
Same basic idea remains with the DB method as well. Only this is probably faster.. Unless of course you want to be able to edit the states via some sort of admin console.
NOTE: You in fact said two character shortcodes only, but my example array looks prettier with full titles. Anyways, as you probably know, you can put the states in whatever format in the array.