vendredi 24 juillet 2020

How can I see which check boxes are checked in PHP?

I'm displaying some columns from a database and at the end of each row I put a check box.

while($row = $result->fetch_assoc()){
    echo "<tr><td>" . $row['Computer Name'] . '</td><td>' . $row['Computer IP'];
    echo ($checkbox)?('<td><input type="checkbox" name="selectSystem"/></td>'):'' . "</td></tr>";
}

(Ignore my $checkbox variable, that's just a function parameter allowing me to toggle the check boxes on/off when I display these rows.)

The code above works fine, but I can't figure out how to output the value (check or unchecked) of these check boxes. It is my understanding that all the check boxes have the same name (selectSystem) and that they should all be in a selectSystem array.

Maybe I'm going about this in the wrong way...I just want the user to be able to select the rows they want in order to reserve a computer system. Is there an easier way to do this or should I just continue on with my stupid check boxes that get rallied up after a submit button is clicked?




Aucun commentaire:

Enregistrer un commentaire