Two checkbox one for foul and one for presence, in this case it seems better one radio button
because only one option can be checked. values m1, m2 ...
Understand as the enrollment or code of the student who from the bank. What should be done is make this radio an array, adding brackets in the name and let either the index be the matricula.
<?php
$alunos = array('m1' => 'joão', 'm2' => 'maria', 'm3' => 'juca', 'm4' => 'paula', 'm5' => 'fulano');
?>
<form action="gravar_falta.php" method="post">
<?php foreach ($alunos as $matricula => $nome){ ?>
<?php echo $nome; ?>
presente
<input type="radio" name="frequencia[<?php echo $matricula; ?>]" value="presente">
falta
<input type="radio" name="frequencia[<?php echo $matricula; ?>]" value="falta"><br>
<?php } ?>
<input type="submit">
</form>
These radios will be sent to php with an array in this structure:
Array
(
[frequencia] => Array
(
[m1] => presente
[m2] => falta
[m3] => falta
[m4] => presente
[m5] => falta
)
)
Finally just do a foreach to insert into the bank :
$aula = 'português';
$frequencias = $_POST['frequencia'];
foreach ($frequencias as $aluno => $frequencia){
insertFequencia($aula, $aluno, $frequencia);
}
Post the code of
form
or ofcheckbox
.– rray
All screen elements are objects accessible by Javascript, so the state is always there as long as the screen does not reload
– Roger Barretto