Dynamically created checkbox list then POST retrieval on another page.
First off, Thanks in advance.
A couple questions regarding best practices with the checkboxes in a form and then $_POST.
Family picture album stuff. I am getting an array back from my brothers database and putting it in a loop.
Question 1- Is it best practices when wanting to retrieve this information on another page to have the "name" be the familyPictureID or should I put that in the "value"?
Sample of table element inside a loop:
<td data-label="Active">
<input class="checky" type="checkbox" name="cList[<?php echo $row['familyPictureID']; ?>]"
<?php if($row['active']==1) { echo 'value="1" CHECKED>';
} else { echo 'value="0">'; }
?>
</td>
Question 2- When retrieving this information on a secondary page, how do I get all the values from the checkboxes? I want to know if they are checked or not but also pair that up with the 'familyPictureID'. Is that correct and best practices?
I am trying to get them like so:
if(!empty($_POST['cList'])) {
echo "check box test <pre>";
print_r($_POST['cList']);
echo "</pre>";
foreach($_POST['cList'] as $familyPictureID) {
echo "check=$familyPictureID<br>";
}
}
I would then send this back to my brothers database with an UPDATE to these family pictures whether they are checked or not.
Does this make sense?
Thanks in advance. I searched for something similar but people on here are doing some complicated stuff that seems way beyond the scope of what I am trying to do.
Thanks! -MT