I am working on an attendance reporting page. Here I am creating a dynamic checkbox with content from db.
I can store the checked student(present) students detail, but I also want to store the absent student. In order to do that I want a hidden field or something to get the unchecked student details please anyone help me to do that.
<form name="myform" action="" method="post">
<div class="checkbox">
<table border="1" cellspacing="2" cellpadding="5" summary="">
<?php while ($row = mysql_fetch_assoc($res)){?>
<tr>
<td>
<input type="checkbox" class="input" id="input<?php echo $row['st_id']; ?>" name="student[]" value="<?php echo $row['st_id']; ?>" checked="checked">
<?php echo $row['st_name'] ; ?>
<label for="input<?php echo $row['st_id']; ?>"></label>
<input type="text" name="absent" value="0"/>
</td>
</tr>
<?php }?>
</table>
<input type="submit" name="submit" value="submit"/>
</div>
PHP code
<?php
$res = mysql_query("SELECT * FROM `student_info` WHERE `sem`='$selsem'");
if(isset($_POST["submit"]))
{
//Here goes array
for($i=0;$i<count($_POST['student']);$i++)
{
$id=$_POST['student'][$i];
echo $id;
$check=1;
mysql_query("insert into manage_attendance(st_id,date,sem,period,subject,status) values('$id','$seldate','$selsem','$selperiod','$selsub','$check')");
}
}
?>