我写的一个在线考试系统 对多选题答案做判断 用的for循环来循环得到的结果 题目被选择的选项个数跟正确答案个数不一样 然后提示本题错误 继续循环下一题 但是 如果被选择的选项个数跟正确答案个数一样的话 不管最后是正确还是错误 都不能在继续循环下一题了 下边是我的代码 大家帮忙看看 哪儿出问题了 先谢谢了···if($_POST['ac'] == 'duoxuan'){
$num = $db->GETALL("select count(*) as num from tol_obj_question where obj_type = 2");
$num = $num['0']['num'];
for($i=1;$i<=$num;$i++){
$string = "item".$i;
if(!isset($_POST[$string])){
echo "<script>alert('您还有没有做完的题目!');history.back();</script>";
}
}
for($i=1;$i<=$num;$i++){
echo $i;
$string = "item".$i;
$result = $_POST[$string];
$id     = $_POST['question_id'];
$num    = count($result); //被选上的选项的数目
$right_num = $db->getall("select count(*) as num from tol_obj_item where item_is_right = 1 and obj_question_id = $id");
$right_num = $right_num['0']['num']; //数据库中正确的选项的数目
if($num == $right_num){
$j = 0;
foreach($result as $v){
if($v == 1){
$j = $j+1;
}
}
if($j == $right_num){
echo '题目'.$i.'、right';
} else {
echo '题目'.$i.'、error';
}
}else{
echo '题目'.$i.'error';
}
echo "正确答案是:";
}
}