Posted by John Canyon
<input type=checkbox name=assnid[1] value=1>
<input type=checkbox name=assnid[2] value=1>
<input type=checkbox name=assnid[3] value=1>
would equal
array
(
0 => 1
1 => 1
2 => 1
)
if all were selected
Actually, the array would equal
array
(
1 => 1
2 => 1
3 => 1
)
You assigned the keys [for some reason] in the form. Even if only the first and last were selected, then you'd have access to the keys $POST['assnid']['1'] and $POST['assnid']['3']
Unless you need to, I wouldn't assign keys to the array.
<input type=checkbox name=assnid[] value="whatever">
<input type=checkbox name=assnid[] value="whatever">
<input type=checkbox name=assnid[] value="whatever">
Then to loop through the array (for EddieFoyJr), you could use a foreach loop
foreach($_POST['assnid'] as $key => $value) {
echo "Key: " . $key . " Value: " . $value . "<br>";
}
Where $key would be 0 1 2 3 and so on (the array key), and $value would be the value that each key holds.
Cgraz