[thelist] Unique combination numbering
João Verde
verde at sardware.com
Fri May 7 09:40:38 CDT 2004
The situation:
=========
I have a form with a field for which there are 5 possible checkboxes.
[EXAMPLE]
Water: [ ] River [ ] Lagoon [ ] Pool [ ] Sea [ ] Other
[/EXAMPLE]
You can check them all, none, or any combination of the 5.
The goal:
======
To save the result in a single field (using MySQL) using a single value (much like those used in CHMOD).
I would need a scheme of numbering the 5 checkboxes so that, whatever the selection, there would never be 2 possible combinations with the same result.
When querying I would know that, for instance, the value 430 would correspond to: X-X-- or 523 to --XX-.
That would simplify my queries and avoid using a separate field for each checkbox (my original idea is to save the values in a CHAR(5) or INT(5) field but that makes queries harder to conduct).
I thought of using primes, and I can certainly do it the hard way and think of every possible combination and attributing a unique number to them, but then again:
The question:
=========
Is there a (simple) mathematical approach to this?
Thanks in advance. I'm puzzled. %-)
More information about the thelist
mailing list