LAMP school attendance system
I am faced with how to tackle this. I have two tables in my database in
relation to this problem:
table 1 student info (studentID, etc)
table 2 student_attendance (student_id, status, date, remark).
I want to capture daily student attendance of a school, student_id
references the studentID, status can either be A (absent) or P (present).
Still not sure if I should use 'absent', 'present', date will be the date
of the attendance while remark might capture more detail or reason for
absence.
I came to a conclusion to use a check box, this is how my code is now, I
am using CodeIgniter, on the view I have this.
My problem is how I get get each value of both the checkbox and text field
(remark) for each student. I wrote a query from the model to get
studentID, and student name from the student table, then the data
transferred to view.
<form action='' method='post'>
<tr>
<thead>
<th class="first" width="10%">S/No.</th>
<th>Name</th>
<th>Present/Absent</th>
<th>Remark</th>
</thead>
</tr>
<?php
$x=1;
foreach($students as $student)
{
$student_id=$student['studentID'];
echo "<tr><td>".$x."</td>";
echo "<td>".$student['name']."</td>";
echo "<td><input type='checkbox' name='student[$student_id]'
value='1'/> </td>";
echo "<td><input type='text' name='remark'/></td></tr>";
$x++;
}
?>
<input type="submit" name="submit" value="send" />
</form>
To insert each data of a particular student using the studentID as a
reference i tried this
if($_POST)
{
$student= $_POST['student'];
foreach($student as $key=>$val)
{
//confuse here a little also i want to get the value
//of remark for each students
}
}
No comments:
Post a Comment