I put them a bit in context, I'm doing an academic attendance record system, and I plan to keep the id of the students in a table along with a value that tells me whether or not they attended classes so that after this a percentage of the absences of each student is taken out.
Above they have the table of how it would be approximately, my idea is that the attendees are marked with a check and the absences are left empty and that is sent. Great once said that we go to the code ...
<?php foreach($resultado as $dato): ?>
<tr>
<td><?php echo $dato["nombre"] ?></td>
<td><?php echo $dato["cedula"] ?></td>
<td><?php echo $dato["acreditable"] ?></td>
<form action="asistencia_dia.php" method="POST">
<td><input type="checkbox" name="asistencia[]"></td>
<input type="hidden" value="<?php echo $dato["id"] ?>" name="estudiante[<?php $dato["id"] ?>]">
</tr>
<?php endforeach ?>
<button type="submit">Enviar</button>
</form>
I explain my disaster a bit: $ result is just a variable which stores a sql sentence, that is supposed to be my form to send 2 data and be able to save them which are the id of each one of the students that are stored in the hidden input and checkboxes.
And he received them this way:
if($_POST){
$estudiante = $_POST["estudiante"];
echo "<ul>";
foreach( $_POST["asistencia"] as $asistencia=> $item1)
{
echo "<li>";
echo $item1;
echo "</li>";
echo $estudiante[$asistencia];
}
echo "</ul>";
}
What they see is just a test, I wanted to visualize that according to the check that it is the corresponding id, I still do not get to the part of saving it in the database.
Once said all that My problem is that although I capture when the checkbox is marked and I see it, I do not detect which one I press, I mean, if for example, checkbox 3 should tell me : on 3, but contrary to that he says: on 1 ..
And my goal is to tell me if I only checkbox 1 tell me: On 1, I mean, that was the check one and so on, if I press the first check and the third one, then tell me: On 1 and On 3 ..
For example: Yes = 1 No = 0
Student Assistance José yes Pedro not Maria yes
You should send me like this yes do not yes
But he sends me like this: yes yes no
That would be my problem, thanks in advance to anyone who can help me, and if you have some time to help me with the rest that I explained, that is to say to save in a database who of the students had a check (I mean they attended) and when not and then do the kind of "counting" to know how many absences or the percentage of absences would have much appreciated. I hope I could have explained my problem well.