Given the context of the question, I am guessing here. But it seems that the you do not understand the checkbox, given that you do not even assign it a value that and this would be a pain to loop through on the form processing end.
Assuming that $list
is an array (borrowing some code from Gazler)
$cnt = count($list);
$checkBoxes = "";
for ($i=1; $i<$cnt; $i++) {
$checkBoxes .= '<p><input type="checkbox" name="checkBoxes" value="' . $i . '">' . $i . '</input></label></p>' . PHP_EOL;
}
echo $checkBoxes . '</legend>' . PHP_EOL . '</fieldset>';
Then on your form processing side, it will be easy to loop through the checked boxes like so:
if (isset($_POST['checkBoxes'])) {
foreach ($_POST['checkBoxes'] as $val) {
// $val will contain the value of the selected boxes
}
}
Using this system, it should get you to where you want to be.