Forum Moderators: coopster
I want to display a drop-down box populated with information from a table.
If I have all of the pieces of data in the MySql database in a single row separated by a comma, will I be able to get them out, explode them and then display them all?
i.e:
row 1: cincinnati, jacksonville, davenport, bryan
or would it be better to have them lined up in separate rows, i.e.
1 cincinnati
2 jacksonville
3 davenport, etc
or, would either work? I would rather do the former, but should be able to work it out either way. Which would you do if you were going to generate a dynamic dropdown?
P
You want to have a table for your cities and assign one a unique id. Whenever you reference that city, use that ID and not the city name. What happens if the City were to rename itself? You could potentially have to manually change a lot of data. And if the City renamed itself to one that currently exists... On the other hand, if you split the city into rows in their own table, you have to change one entry. The city name changing scenario is pretty extreme, but having a misspelling that goes unchecked or two cities with the same name is pretty common.
Really, anytime you have a comma delimited list in a row, you should have to justify it. I'm not saying it's always wrong, but it's something you should have reservations about.
But like I said, both would work.