每当单击按钮时,如何打印获取的mysql数据的下一行?

时间:2019-03-27 17:29:37

标签: php html mysqli

不知道单击按钮时如何更新或获取下一行数据。

我已经成功连接到数据库并检索了数据,并以结果表的形式将其制成表格。

<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="css/html.css">
  <head>
    <title>Welcome to my quiz! \(* 3 *)/</title>
  </head>
  <body>
  <h1>Welcome to my quiz</h1>
  <link rel="stylesheet" type="text/css" href="css/background.css">

    <?php


         $conn = new mysqli("jdbc:mysql://localhost:3306/quizapp?useSSL=false&serverTimezone=UTC", "myuser", "1234");

         $result=mysqli_query($conn,"SELECT id, question, optionA, optionB, optionC, optionD FROM question");

         $count=0;

        if($row=mysqli_fetch_array($result))
          {
            echo $row['id']. ". " . $row['question'];
            echo "<br>";
            echo "<br>";
            echo "A. ".$row['optionA'];
            echo "<br>";
            echo "<br>";
            echo "B. ".$row['optionB'];
            echo "<br>";
            echo "<br>";
            echo "C. ".$row['optionC'];
            echo "<br>";
            echo "<br>";
            echo "D. ".$row['optionD'];
            echo "<br>";
            echo "<br>";
          }


    ?>   

 <form> <input type="button" value="Next" onclick="alert('You clicked the button!')"> </form>




  </body>
</html>  

单击按钮时,我可以用哪种方式对其进行编码,以便可以继续处理下一行数据(选项A,B,C,D的下一个问题)?

0 个答案:

没有答案