I am trying to create a student attendance table that contains a checkbox for each students attendance, that is to be stored in a database.
This is my table that I have so far, that is executed from an ajax function call. Most of the data is from a database, that contains student names.
For the sake of this example $numStudent = 5;
echo '<form method="post" action="checkAttend.php">
<table border="1">';
$count = 1;
while(($count < $numStudent) && ($students = mysqli_fetch_assoc($result))) {
echo '<tr>
<th>' . $count. '</th>
<th>' . $students['student_name'] . '</th>
<th> <input type="checkbox" name="students[]" /> </th>
</tr>';
$count++;
}
echo '<th colspan = "3">
<input type="submit" name="button" id="button" value="Submit" /> </th>';
echo '</table>';
echo '</form>';
In checkAttend.php
The form prints exactly the way I need it to, but when I try to print out the values in the checkbox array (to check what values are contained within before saving it to the database) each value in the array prints out :
$student_attend[0] A
$student_attend[1] r
$student_attend[2] r
$student_attend[3] a
$student_attend[4] y
Typically I want to store some kind of value in the corresponding field in the database to indicate if the student is absent or not.
I cant tell if I am doing the checkbox loop correctly or not or if I need to add in more stuff.
Aucun commentaire:
Enregistrer un commentaire