to loud the last question
This commit is contained in:
16
testdb.php
16
testdb.php
@@ -6,25 +6,20 @@
|
||||
$p = 20;
|
||||
$pp = 0;
|
||||
$ppp = $p + $pp;//the number of questions
|
||||
echo "<div id=\"ppp\" ppp=\"".$ppp."\"></div>\n<div class=\"section\" id=\"hiddenBefore\" style=\"\"><h5> 单选题</h5>\n";
|
||||
echo "<div id=\"ppp\" ppp=\"".$ppp."\"></div>\n<div class=\"section\" id=\"hiddenBefore\"><h5> 单选题</h5>\n";
|
||||
//创建随机数组
|
||||
$randomArray = array_rand(range(1,99),$p+1);
|
||||
// for($i = 1;$i <= $p;$i++){
|
||||
// echo $randomArray[$i]." ";
|
||||
// }
|
||||
shuffle($randomArray);
|
||||
$count = 0;
|
||||
for($i = 1;$i <= $p;$i++){
|
||||
$flag = 0;
|
||||
$random = $randomArray[$i];
|
||||
$result = mysqli_query($con,"SELECT * FROM Persons WHERE num='$random'");
|
||||
$row = mysqli_fetch_array($result);
|
||||
$count += 1;
|
||||
echo "当前查询次数:$count, 查询行数: $random, 查询题号: $i";
|
||||
while($row = mysqli_fetch_array($result)){
|
||||
//html
|
||||
if($row) {
|
||||
$flag = 1;
|
||||
}
|
||||
echo "<div class=\"spbq\" name=\"div_e\"><div class=\"biankuang biankuang_1\"></div><div class=\"biankuang biankuang_2\"></div><div class=\"biankuang biankuang_3\"></div><div class=\"biankuang biankuang_4\"></div>";
|
||||
echo "<h6 id=\"question_".$i."\">". $i. ".". $row['q'] ."</h6>\n<p>";
|
||||
echo "<input class=\"with-gap\" type=\"radio\" name=\"answer_". $i. "\" value=\"1\" id=\"test". $i. "1\" onclick=\"addOne(this)\"/>\n<label for=\"test". $i. "1\">". $row['A'] ."</label>\n";
|
||||
@@ -35,12 +30,11 @@
|
||||
}
|
||||
echo "</p></div>\n";
|
||||
echo "<div class=\"input-field col s12\" style=\"height:1px;overflow:hidden\"><input value=\"".$random."\" type=\"text\" class=\"validate\" style=\"color:#fff\" name=\"question_".$i."\"></div>\n";
|
||||
|
||||
echo $flag;
|
||||
}
|
||||
if($flag == 0){
|
||||
$randomArray[$i]++;
|
||||
$i--;
|
||||
echo $i;
|
||||
sleep(1);
|
||||
sleep(0.4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user