Ok, so I have been asked to help with an existing website. They have a form that users can submit information. One of the fields used to be a radio button selection but they changed it to checkboxes so that the user could select more than one option. They did it right as far as the checkboxes work and multiple selections get entered into the field in the database in a comma separated format. So they thought they were good and couldn't figure out why they can no longer select from the database where the field had one of the selections that they were looking for. What I mean is something like this:
The data from the insert from the checkboxes would put something like this in the field:
Tucson, Phoenix, Mesa
And they were running another function that was saying:
select * from eventstable where city = 'Tucson'
but it would not select the record. To you and I that makes sense, but I had a hard time explaining to them why it doesn't work. So that leads me to them asking for help.
So I am looking at a couple of different options here to address this:
1. Change the insert process to loop through each of the values in the checkboxes, inserting a record for each one with all the other data being the same, only entering one value for city per record.
2. Tackle it on the other end and create a triger that will go after each insert, that will see if there was more than one value entered in the city field and break that record into multiple records, having the same effect as the other option.
I have more experince working in SQL than PHP, so the first option is less attractive for me to tackle. But I don't want to let my fear of what I'm not used to prevent me from doing something that would be easy if I just learned how to do it.
Opinions?