Quote:
|
checkboxes name is "specialties[]
|
.... what values do you give each checkbox?
I think we'll all do this a little different. I don't know if my way is the best method or not.
I usually give my list of checkboxes (named as an array like yours), the values:
.. name="specialties[]" value="1" ...
.. name="specialties[]" value="2" ...
.. name="specialties[]" value="3" ...
etc.
I know what those values refer to ... example, 2 is "Audio/Visual Packaging".
So when the PHP script processes the checkbox array, the array only contains
which boxes were checked. So let's say I had checked four of the items ...
I do a foreach through the checkbox array and build a string ...
The values of each checkbox separated by pipes |
2|4|5|6|
I save that in the table column (or field) you might call "specialties".
Any script that needs to know what specialties they selected, you
explode the string (delimiter is pipe |) and now you know which checkboxes
they selected.
If you add more checkboxes to your "specialties" list, it won't affect anything.
Right now you have 11 items ... but say you add 5 more. When I fill out your
form, my list of checkboxes might look like this:
5|6|11|13|14|
So now you would know which checkboxes they selected.
When you render the form once more, as I mentioned before, you explode
the "specialties" string and using "if" statements in your HTML form, you decide
if the checkbox tag should have the checked="checked" property or not.
That's the way I do it.
I like the idea of only using 1 column in my table for the whole checkbox array.
It seems to make it easier to troubleshoot as well.
.