From e99edee1ec9a46b651c6a363f2d07b8be41c892c Mon Sep 17 00:00:00 2001 From: xice Date: Sat, 14 Jul 2018 22:44:22 +0800 Subject: [PATCH] to loud the last question --- testdb.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/testdb.php b/testdb.php index 0447289..3c5b9a0 100644 --- a/testdb.php +++ b/testdb.php @@ -6,25 +6,20 @@ $p = 20; $pp = 0; $ppp = $p + $pp;//the number of questions - echo "
\n
  单选题
\n"; + echo "
\n
  单选题
\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; - } + $flag = 1; echo "
"; echo "
". $i. ".". $row['q'] ."
\n

"; echo "\n\n"; @@ -35,12 +30,11 @@ } echo "

\n"; echo "
\n"; - - echo $flag; + } if($flag == 0){ + $randomArray[$i]++; $i--; - echo $i; - sleep(1); + sleep(0.4); } }