I have 3 checkboxes where the user can select whatever he wants. I would like to store his selection in the database into one field.
I was thinking of encoding it into a String:
0: nothing selected
100: first selected
101: first & third selected
etc.
I think that’s a nice way. However, how do I extract the information again? Using substr() to get each checkbox’s state?
Is there a better way of encoding/decoding this information?
Thanks a lot
Martin
Packing the information into a single database field like this makes queries tricky. Do you really need to pack the three checkboxes into a single field? Why not three boolean fields?
If it really must be one field then why strings? An 8 bit int would be big enough to hold up to 8 checkbox states.