I am working on an attendance reporting page.Here i am creating a dynamic checkbox with content from db.Now I can store the checked student(present) students detail i also want to store the absent student.I order to do that i want a hiden field or something for get the unchecked students detail 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')");
}
}
?>
Aucun commentaire:
Enregistrer un commentaire