我有 2 个表,其中包含 id、subject、exam、qution、qution_id,在表 2 中的表 1 中 id、question_id、answer、正确,这里我有一个问题要从我正在使用的数据库中获取随机问题
$singleSQL = mysql_query("SELECT * FROM questions WHERE id='$question' LIMIT 1");
while($row = mysql_fetch_array($singleSQL)){
$id = $row['id'];
$thisQuestion = $row['question'];
$type = $row['type'];
$subject =$row['subject'];
$exam =$row['exam'];
$explan =$row['explan'];
$question_id = $row['question_id'];
$s ='<strong>'.$subject.'</strong>';
$e ='<small>'.$exam.'</small>';
$q = '<h2>'.$thisQuestion.'</h2>';
$ex ='<p class="exp">'.$explan.'</p>';
$sql2 = mysql_query("SELECT * FROM answers WHERE question_id='$question' ORDER BY rand()");
while($row2 = mysql_fetch_array($sql2)){
$answer = $row2['answer'];
$correct = $row2['correct'];
$answers .= '<table class="table table-hover table-bordered"> <tr>
<td><label style="cursor:pointer;"><input type="radio" name="rads" value="'.$correct.'">'.$answer.'</label></td>
</tr></table>
<input type="hidden" id="qid" value="'.$id.'" name="qid"><br />
';
}
$output = ''.$s.','.$e.''.$q.','.$answers.''.$ex.' <span id="btnSpan"><button onclick="post_answer()" id="show">Submit</button></span>';
echo $output;
}
}
当我单击提交答案时,我应该随机得到下一个问题,例如
index.php?question=
当页面加载时我应该在这里使用什么它应该从数据库中得到一个随机问题请帮助我提前需要这个thanx