Welcome Guest, Not a member yet? Register   Sign In
Best way to store "choose all that apply" type questions.
#2

[eluser]WanWizard[/eluser]
I've used two implementations in the past, depending on the situation.

I sometimes use a large enough varchar or text field, and use implode() to flatten an array with choices. The advantage is that you can name your options ('cola|beer|water'), so you have a direct link between the stored data and your options, even if you reorder them or add new options. Downside is that you need more storage, and you have variable length fields, which is slightly slower performance wise.

Sometimes I use an integer, and bit operators. bit = 1, option is selected, bit =0, option not selected. This requires a fixed option order, as you need to know which bit belongs to which option. But it requires only a few bytes of storage, and creates fixed length records (unless you have other fields of course).


Messages In This Thread
Best way to store "choose all that apply" type questions. - by El Forum - 07-28-2010, 09:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB