Code for Form in PHP
echo "<form name=myfm method=post action=insert_answers.php>";
echo"<fieldset>";
$n=$question_count;
echo "<table width=100%>";
echo "<tr><td><input type=hidden name=member[question][] value='".$row_prathmesh['que_id']."'> Que ". $n .":'".$row_prathmesh['que_desc']."';";echo"</td><tr>";
//member[ans1][]
echo "<tr><td><input type=checkbox name=member[group][] value=1>$row_prathmesh[3]";echo"</td><tr>";
echo "<tr><td><input type=checkbox name=member[group][] value=2>$row_prathmesh[4]";echo"</td><tr>";
echo "<tr><td><input type=checkbox name=member[group][] value=3>$row_prathmesh[5]";echo"</td><tr>";
echo "<tr><td><input type=checkbox name=member[group][] value=4>$row_prathmesh[6]";echo"</td><tr>";
$question_count++;
echo "</table>";
echo"</fieldset>";
echo"<br>";
}
echo"<input type=submit name=submit value=Submit></form>";
-------------------------------------------------------------------------------------------------------------------------echo "<form name=myfm method=post action=insert_answers.php>";
echo"<fieldset>";
$n=$question_count;
echo "<table width=100%>";
echo "<tr><td><input type=hidden name=member[question][] value='".$row_prathmesh['que_id']."'> Que ". $n .":'".$row_prathmesh['que_desc']."';";echo"</td><tr>";
//member[ans1][]
echo "<tr><td><input type=checkbox name=member[group][] value=1>$row_prathmesh[3]";echo"</td><tr>";
echo "<tr><td><input type=checkbox name=member[group][] value=2>$row_prathmesh[4]";echo"</td><tr>";
echo "<tr><td><input type=checkbox name=member[group][] value=3>$row_prathmesh[5]";echo"</td><tr>";
echo "<tr><td><input type=checkbox name=member[group][] value=4>$row_prathmesh[6]";echo"</td><tr>";
$question_count++;
echo "</table>";
echo"</fieldset>";
echo"<br>";
}
echo"<input type=submit name=submit value=Submit></form>";
Inserting Record In database while using multiple checkboxes
for($i=0 ;$i <= count($_POST['member']); $i++)
{
$member=$_POST['member'];
//$ans=$_POST['ans'];
echo $ques_id_111=$_POST['member']['question'][$i];
echo $row_abc="select * from mst_question where que_id='".$_POST['member']['question'][$i]."'";
$row_abc=mysql_query($row_abc) or die(mysql_error());
while($row_abc=mysql_fetch_array($row_abc))
{
echo $que_id= $row_abc['que_id'];
echo $row_abc['test_id'];
echo $row_abc['question_no'];
echo $row_abc['que_desc'];
echo $row_abc['ans1'];
echo"
";
echo $row_abc['ans2'];
echo"
";
echo $row_abc['ans3'];
echo"
";
echo $row_abc['ans4'];
echo"
";
echo $row_abc['true_ans'];
echo "answer of user=".$_POST['member']['group'][$i];echo"
";
$chk="";
$checkbox11=$_POST['member']['group'][$i];
echo insert1="insert into mst_useranswer(sess_id,test_id,que_id,que_des, ans1,ans2,ans3,ans4,true_ans,your_ans) values ('$session_id','".$row_abc['test_id']."','".$row_abc['que_id']."','".$row_abc['que_desc']."','".$row_abc['ans1']."','".$row_abc['ans2']."', '".$row_abc['ans3']."','".$row['ans4']."','".$row_abc['true_ans']."','".$_POST['member']['group'][$i]."')";
mysql_query($insert1) or die(mysql_error());
echo"
";
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------
Screenshot