Best practice for creating long dropdowns. ie. for countries and US States |
[eluser]rhussain[/eluser]
Hi, I'm a newbie with CI and I'm sure glad I discovered it!!! Thanks to all that have contributed to it. My question is... What would be the best practice for setting the large arrays that would be used to populate a dropdown for Countries and US States etc. Where should I be declaring the the arrays? I have them in the view at the moment but it makes a short file very long! Is there somewhere more approriate to declare the arrays? By the way I'm using form_dropdown('country', $countries) in my view file. Thanks in advance.
[eluser]Atharva[/eluser]
You should use database to store countries and state. Here is how you can access countries Code: //in your model some_model.php Same goes for state.
[eluser]LuckyFella73[/eluser]
Like Atharve I would do it with db tables too. There are several sql files available to download with all the country data you need. For example this one: http://goneale.com/files/code/Iso3166CountryList.sql Of course there are other sql file around the net - maybe this one allready fits to your needs.
[eluser]rhussain[/eluser]
Thank you both for your replies. I'll take your advice. @Atharva: And thanks for the code snippet. I also found his link for the states: http://snipplr.com/view/6637/mysql-table--us-states/ |
Welcome Guest, Not a member yet? Register Sign In |