mardi 19 juin 2018

Multiple checkbox selected in a loop PHP

I have a loop that offers several checkboxes to the user:

<?php
while($personInfo = $selectPerson->fetch())
{
?>

    <label>
    <input type="checkbox" name="checkBoxValue[]" id="checkBoxValue" value="<?= $personInfo['title'] ?>"> <?= $personInfo['title'] ?>&nbsp&nbsp&nbsp
    </label> | 
    <label>
    <input type="checkbox" name="improper" id="improper" value="0"> Improper
    </label>
    <hr>

<?php
}
?>

The thing is that I manage to recover each checkbox selected by the user with:

foreach($_POST['checkBoxValue'] as $selected)
{
    echo $selected;
    echo "<hr>";
}

But I do not see how I can know if for each checkbox selected, the checkbox "Improper" is also selected.




Aucun commentaire:

Enregistrer un commentaire