I want to take students attendance.
i had made a page attendance.php
This is coding part
<?php
$report = mysql_query("SELECT id, name, rollno FROM registered_members") or die(mysql_error());
?>
<form action="attendinsert.php" method="post">
<table id = "attendance" width="567" border="1 bold">
<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">Attendance</th>
</tr>
<?php while(list($id, $name, $rollno) = mysql_fetch_row($report))
{
?>
<tr>
<td><?php echo $id ?></td>
<td><?php echo $name ?></td>
<td><?php echo $rollno ?></td>
<td align="center"><?php echo '<input type="hidden" name="att[]" value="0"/>';?><?php echo '<input type="checkbox" checked="checked" name="att[]" value="1" />'; ?></td>
<input type="hidden" name="rollno[]" value="<?php echo $rollno; ?>" />
</tr>
<?php
}
echo '</table>';
?>
<input type="submit" name ="submit2" id="submit2" value ="submit"></input>
</form>
///////////////////////////////////////////////////////
And the second page is attendinsert.php
by which i want to save data in attendance table
<?php
$att = $_POST['att'];
$rollno = $_POST['rollno'];
foreach($att as $key => $attendance) {
$at = $attendance ? '1' : '0';
$query = "INSERT INTO `attendance`(`rollno`,`att`) VALUES ('".$rollno[$key]."','".$at."') ";
$result = mysql_query($query);
}
?>
I dont know whats the error. on line
$query = "INSERT INTO `attendance`(`rollno`,`att`) VALUES ('".$rollno[$key]."','".$at."') ";