<?php
$qq=mysql_query("select * from quiz");
$row=mysql_fetch_array($qq);
//var_dump($row);
$question = $row['question'];
$_SESSION['quiz_id']=$row['id'];
$ans_array = array($row['answer1'],$row['answer2'],$row['answer3'],$row['answer4']);
shuffle($ans_array);
?>
<form name="qform" id="qform">
<h2> <?php echo $question; ?></h2>
<label><input type="radio" value="<?php echo $ans_array[0]; ?>" name="answer"> <?php echo $ans_array[0]; ?></label>
<label><input type="radio" value="<?php echo $ans_array[1]; ?>" name="answer"> <?php echo $ans_array[1]; ?></label>
<label><input type="radio" value="<?php echo $ans_array[2]; ?>" name="answer"> <?php echo $ans_array[2]; ?></label>
<label><input type="radio" value="<?php echo $ans_array[3]; ?>" name="answer"> <?php echo $ans_array[3]; ?></label>
<p id="submit-row-btn"><input type="submit" id="quiz_submit" class="q_submit" value="Submit">
<input type="submit" id="quiz_ans_submit" value="Check Answer" class="q_submit" style="display:none">
<span id="ans_err"></span></p>
</form>
在我的MySQL表中,我已经存储了;
id question answer1 answer2 answer3 answer4 ans_key date
1 1+1= 2 3 1 6 1 2014-08-03
这里是 ans_key;
我使用 AJAX 发送用户的答案。
我想检查答案键与相关值,数组 Shuffle 后,如何得到键值来检查答案是否正确?
2条答案
按热度按时间waxmsbnn1#
我找到了答案
这里data-key保存数组的键值
ijxebb2r2#