[php]代码库
<?php
$query=$mysql_query("select * from 'panduan'");
$results=$mysql_fetch_row($query);
$rand=array_rand($results,3);//取出随机的三个问题,注意这里取得是三个键值
$question=array($result[$rand[0]],$result[$rand[1]],$result[$rand[2]]);//将取出的三个问题放进一个数组中
?>
<form action="login.php" method="post">
<?php
foreach($question as $values)
{
 $options=explode(";",$values['options']);//用“;”将选项分割存进数组
 echo $values['questions'];//显示题目
 for($i=0;$i<count($options);$i++){
 echo "<input type='radio' name=".$choice[$valest['id']]." value='A' >".$options[i]." /><br>";//输出选项
 }
echo "----------------------------------------";//题目之间分隔符
}
//下面的代码是你接受form表单的页面,如果是本页面就直接接着上面的代码写
 if(!empty($_POST[$choice]))
 {
 foreach($_POST[$choice] as $key=> $data)
 {
 $question_id=$key;
 $user_choice=$data;
 if(mysql_query("select * from 'panduan' where id=".$key."and right_answer='".$data."'"))
 {
 //答案对如何处理。。。。
 }
 else
 {
 //答案不对处理办法。。。。
 } 
 }
 }
?>
</form>
初级程序员
by: bbwikf 发表于:2019-09-17 13:35:53 顶(0) | 踩(0) 回复
沙发
回复评论