Save questions to an array.
while ($row = mysqli_fetch_array($results, MYSQL_NUM)){ $questions[] = $row[0];}
shuffle($questions);shuffle($questions);shuffle($questions);
$ndx = 0;
Then grab the questions one at a time.
$question= array_slice($questions, $ndx, 1);
$ndx++;
You will not get duplicate questions.
Performance is excellent.
Line1: Creates array questions from query results (query excluded)
Line 2: Shuffles questions 3x array for randomization.
Generate Question HTML
(Untested)
echo '<div id="questionBox"><form method="POST" action="score.php" >';
foreach ($question as $k=>$q){
echo "<div id=\"q$k\"><fieldset><legend>$k</legend><div class=\"q\">$q[1]</div><input class=\"true\" type=\"radio\" name=\"a$q[0]\" value=\"1\" /> True</div><br><div id=\"a$question[0]\" class=\"false\"><input class=\"false\" type=\"radio\" name=\"a$q[0]\" value=\"0\" /> False</div><button onclick=\"next($k)\">Next</button></fieldset></div>\n";
}
echo '<div id="q' . $k . '"><input type="submit" name="Score" Value="Score" /></div></form></div>";
JS
(Untested)
echo <<<EOT
<script type="text/javascript">
//<![CDATA[
var q = new Array;
var divs = document.getElementsByTagName("div");
for (var div=1;div<divs.length;div++){
did = divs[div].getAttribute("id");
if (did == null){continue;}
divs[div].style.display='none;
q.push(div);
}
document.getElementById['q1'].style.display='block';
function next(a){
q[a].style.display='none;
q[a+1].style.display='block;
}
//]]>
</script>
EOT;