I’m working on a PHP project where I need to mark student attendance. I’ve already fetched the students from the database based on their class and section, and displayed them in a table. Each row has a student’s name and two radio buttons — one for Present and one for Absent.
My main challenge is:
How can I structure the radio button inputs and handle the form submission in PHP to store each student’s attendance status in the database?
<tr>
<td class="text-center">
<?php echo($no++);?>
</td>
<td class="text-center">
<?php echo($studentId); ?>
</td>
<td class="text-center">
<?php echo($studentName); ?>
</td>
<td class="text-center">
<?php echo($fullClassName); ?>
</td>
<td class="text-center">
<?php echo($attType); ?>
</td>
<td class="text-center">
<label for="">Pre</label>
<input type="radio" value="">
<label for="">abs</label>
<input type="radio" value="">
</td>
</tr>
What I want to achieve:
When the form is submitted, loop through the attendance input in PHP.
Insert the attendance into a database table with fields like:
student_id
teacher_id
status (present or absent)
date