Hi to all. I am a newbie to PHP programming. In my project I'm having a student registration form. In that page I've populated checkboxes from database values for students who wants to enroll more than one classes. Everything got done. Now I need to give edit option to student in case they want to change the class selection. I tried the below code for show checked classes. It shows the perfect answer (I mean my table have 5 classes for example when the time of registration student selected 2 checkboxes my below code shows the exactly what they've selected) But what I want is I need to show previously selected classes as checked as well as rest as unchecked.
<?php $stu_id = $rows["id"];?>
<?php
$data = mysql_query("select a.id as id ,a.class_name as class_name from class a,stud_class b where b.class_id = a.id and b.stud_id = '$stu_id'") or die(mysql_error());
while ($val = mysql_fetch_array($data))
{ ?>
<input type="checkbox" name="class[]" id="class" value="<?php print $val['id']; ?>">
<?php print isset($val['class_name'])?$val['class_name']:""; ?> <br>
<?php }
?>
Please anyone help me with this. Thanks in advance