I am trying to develop a attendance management system.. I have one master table of students which contains details like student name, roll no, class and so on.. Here is my form for registering the students. I have a connection to database already.
[html]<form id="form1" name="form1" method="post" action="process.php">
<fieldset>
<legend>Student Registration Form</legend>
<p>Student Name:
<label for="stud_name"></label>
<input type="text" name="stud_name" id="stud_name" />
</p>
<p>Student Roll No:
<label for="stud_roll"></label>
<input type="text" name="stud_roll" id="stud_roll" />
</p>
<p>Class:
<label for="stud_class"></label>
<input type="text" name="stud_class" id="stud_class" />
</p>
<p>Contact Number:
<label for="stud_contact"></label>
<input type="text" name="stud_contact" id="stud_contact" />
</p>
<p>Father's Name:
<label for="stud_father"></label>
<input type="text" name="stud_father" id="stud_father" />
</p>
<p>Mother's Name:
<label for="stud_mother"></label>
<input type="text" name="stud_mother" id="stud_mother" />
</p>
<p>Parent Contact Number:
<label for="stud_parent_contact"></label>
<input type="text" name="stud_parent_contact" id="stud_parent_contact" />
</p>
<p>Address:
<label for="stud_address"></label>
<input type="text" name="stud_address" id="stud_address" />
</p>
<p>
<input type="submit" name="submit" id="submit" value="Submit" />
</p>
</fieldset>
</form>[/html]
and now process.php and id is primary key.
PHP Code:
if(isset($_POST['submit']))
{
$studname = $_POST['stud_name'];
$studroll = $_POST['stud_roll'];
$studclass = $_POST['stud_class'];
$studcontact = $_POST['stud_contact'];
$studfather = $_POST['stud_father'];
$studmother = $_POST['stud_mother'];
$studparentcontact = $_POST['stud_parent_contact'];
$studaddress = $_POST['stud_address'];
$query = "INSERT INTO `student`(`id`, `studname`, `studroll`, `studclass`, `studcontact`, `studfather`, `studmother`, `studparentcontact`, `studaddress`, `addedon`) VALUES (NULL,'$studname','$studroll','$studclass','$studcontact','$studfather','$studmother','$studparentcontact','$studaddress',CURRENT_TIMESTAMP)";
$result = mysql_query($query);
}
if($result)
{
echo"done";
}
else
{
echo"no";
}
?>
so after inserting some values, my database looks like this
Now I need to take attendance of particular class, say 5th. For this I need to pull out data from the student table for the student's name. For this I have att.php file
PHP Code:
$report = mysql_query("SELECT id, studname, studroll FROM student WHERE studclass = 5 ") or die(mysql_error());
[html]<form action="process1.php" method="post">
<table width="567" border="1">
<tr>
<th width="83" scope="col">ID</th>
<th width="83" scope="col">Student Name</th>
<th width="55" scope="col">Student Roll.No</th>
<th width="51" scope="col">Present</th>
<th width="68" scope="col">Absent</th>
<th width="276" scope="col">Remarks of Absentees</th>
</tr>[/html]
PHP Code:
while($info = mysql_fetch_array($report))
{
[html]<tr>
<td>[/html]
PHP Code:
echo $info['id'];
[html]</td>
<td>[/html]
PHP Code:
echo $info['studname'];
[html]</td>
<td>[/html]
PHP Code:
echo $info['studroll'];
[html]</td>
<td align="center"><input type="checkbox" name="pre[]" id="pre" value="P" />
<label for="pre"></label></td>
<td align="center"><input type="checkbox" name="abs[]" id="abs" value="A" />
<label for="abs"></label></td>
<td align="center"><label for="remarks"></label>
<input type="text" name="remarks" id="remarks" /></td>
</tr>[/html]
PHP Code:
}
echo "</table>";
[html]<input type="submit" name="submit" id="submit" value="Submit" />
</form>[/html]
And I have a table in database for attendance. So when I mark the attendance through selecting the checkbox, the value should get inserted in the database with the same id as in the student table(master table). I have established a foreign key in the attendance table and below are the images
This is what i did till now. Now my doubt is when i click submit in att.php the details should get updated in attendance table with corresponding id's of the respective students. I hope you got the point. My intention is in whicever table data gets updated it should be with the id of the student. When i check the checkbox of all students and click submit the data should go into attendance table. For this i have tried with foreach loop
PHP Code:
foreach($present as $p)
where
PHP Code:
$present = $_POST['pre'];
and same for absent. Now i am stuck with database part. how do i update or insert data into attendance table. Kindly help..