单击提交后,从mysqli查询中获取更多数据

时间:2018-08-26 15:50:55

标签: php mysqli

我正在运行这段代码。

while ($row = mysqli_fetch_array($result)) {
    $qID = $row['question_id'];
    $a = $row['answerA'];
    $b = $row['answerB'];
    $c = $row['answerC'];
    $d = $row['answerD'];
    $rA = $row['rightAnswer'];
    echo "QID: " . $row["question_id"]. "<br>".
    "Question Type: " . $row["questionType"]. "<br><br>" .
    "Question: " . $row["question"]. "<br><br><br>";
    echo "<input type = 'Radio' Name = 'Answer[$qID]' value ='A' > A.  $a &nbsp;&nbsp;<br>";
    echo "<input type = 'Radio' Name = 'Answer[$qID]' value ='B' > B.  $b &nbsp;&nbsp;<br>";
    echo "<input type = 'Radio' Name = 'Answer[$qID]' value ='C' > C.  $c &nbsp;&nbsp;<br>";
    echo "<input type = 'Radio' Name = 'Answer[$qID]' value ='D' > D.  $d &nbsp;&nbsp;<br><br>";
    echo "<input name='submit' type='submit' value='Submit'><br><br>";
    if(isset($_POST['Submit'])) {
        echo "Right Answer: " .$row["rightAnswer"]. "<br><hr>";
    }

当我导航到页面时,最后一行的数据已经显示。

如何获取信息,以便用户单击“提交”时显示“正确答案:”,而不是在导航到网页后立即显示?

我知道我的单选按钮目前基本上没有用。那是另外一次,我至少想尝试找出那个。

这是显示内容的示例。

enter image description here

0 个答案:

没有答案