php單選post數組
我想通過這個代碼實現試卷試題的產生,通過迴圈產生了單選題目,並想通過數組POST給驗證頁面進行評分,但是我發現無法擷取check[]數組,也無法POST到目標頁面。
作為新手,目的是想實現功能,因此代碼很冗雜- -
quesid[$i]數組可以正常傳遞給目標頁面。
真心求教。
代碼如下:
試卷
session_start(); if(isset($_SESSION['id'])){ $admin = $_SESSION['id']; $query = "select * from admin_info where admin_id = '$admin'"; //select admin information $result = mysqli_query($dbc,$query); $rows = mysqli_fetch_array($result); $admin_name = $rows['admin_name']; $admin_id = $rows['admin_id']; echo "
"; echo ''.$admin_name.'('.$admin_id.')您好!
'; } ?> //get sql test information $query = "select * from test_info where test_number = '000'"; $result = mysqli_query($dbc,$query); $rows = mysqli_fetch_array($result); $update_name = $rows['update_name']; $test_number = $rows['test_number']; $test_name = $rows['test_name']; $class_one = $rows['class_one']/100; $class_two = $rows['class_two']/100; $class_three = $rows['class_three']/100; $danx_quantity = $rows['danx_quantity']; $duox_quantity = $rows['duox_quantity']; $pand_quantity = $rows['pand_quantity']; $test_uptime = $rows['test_uptime']; $test_start = $rows['test_start']; $test_end = $rows['test_end']; $test_duration = $rows['test_duration']; $test_status = $rows['test_status']; ?>
echo ''.$test_name.''; echo '注意: 1.你有'.$test_duration.'的時間答題,請把握好時間; 2.理論考試包含有單選題:'.$danx_quantity.'題、多選題:'.$duox_quantity.'題、判斷題:'.$pand_quantity.'題; 3.各部分內容所佔比例為,政治理論基礎:'.($class_one*100).'%、 條令條例:'.($class_two*100).'%、軍兵種常識與軍事高技術:'.($class_three*100).'%。 '; ?> |
一、單項選擇題 $danx_quantity; $class_one_num = round(($danx_quantity*$class_one),0); $class_two_num = round(($danx_quantity*$class_two),0); $class_three_num = ($danx_quantity - $class_one_num - $class_two_num); //科目一 for($id = 1,$sub_id = 1,$c1_id = 1;$sub_id '.$question_cont.'
'; echo ''; echo ' A.'.$danx_choiceA.' '; echo ' B.'.$danx_choiceB.' '; echo ' C.'.$danx_choiceC.' '; if($danx_choiceD != NULL){ echo ' D.'.$danx_choiceD.' '; } else { echo ' '; } echo ''; echo ' '; echo "---------------------- "; } //科目二 for($sub_id,$id,$c2_id = 1;$sub_id "$question_id"); $ques_id[$id] = $question_id; echo '['.$ques_id[$id].']'; echo ' '.$question_cont.'
'; echo ''; echo ' A.'.$danx_choiceA.' '; echo ' B.'.$danx_choiceB.' '; echo ' C.'.$danx_choiceC.' '; if($danx_choiceD != NULL){ echo ' D.'.$danx_choiceD.' '; } else { echo ' '; } echo ''; echo ' '; echo "---------------------- "; } //科目三 for($sub_id,$id,$c3_id = 1;$sub_id '.$question_cont.'
'; echo ''; echo ' A.'.$danx_choiceA.' '; echo ' B.'.$danx_choiceB.' '; echo ' C.'.$danx_choiceC.' '; if($danx_choiceD != NULL){ echo ' D.'.$danx_choiceD.' '; } else { echo ' '; } echo ''; echo ' '; echo "---------------------- "; } ?> |
|
for($i = 1;$i "; } ?>
返回上級| 退出登入
POST目標頁面:test_check.php
for($i=1;$i <=100;$i++)
{
$check[$i] = $_POST['check'][$i];
$ques[$i] = $_POST['quesid'][$i];
}
print_r($check);
echo "
";
print_r($ques);
?>