By adding those up you'll have no way to know which ones were checked (you'll only have the total)
You may be better off using bit flags for the values, e.g.
PHP Code:
<input name="item[rose]" type="checkbox" id="ROSE" value="1" />
<input name="item[red]" type="checkbox" id="RED" value="2" />
<input name="item[white]" type="checkbox" id="WHITE" value="4" />
Then add them up:
PHP Code:
$total = 0;
foreach ($_POST['items'] as $value) {
$total |= $value;
}
Now you can do:
PHP Code:
//Was rose checked?
if (1 & $total) {
//...
}
//were both red and white checked?
if (6 & $total) {
//..
}
//were all 3 checked?
if (7 & $total) {
//..
}
It also provides a convenient way to store the selection in a single database field.
Bookmarks