php echo在表单中不起作用

时间:2013-02-15 23:44:48

标签: php forms mysqli echo

我的代码似乎没有工作..单选按钮出现但旁边没有任何东西..似乎mysql_fetch_row由于某种原因不起作用,因为我已经玩了代码并将$ qnumber手动替换为值测试它然而没有出现。有人可以请问有什么问题吗?欢呼ps。我是新来的。

这是我的代码。

<?php

include 'dbyear2.php';

$qnumber = ($_REQUEST['uqn']); // obtain question number from URL

$find = mysqli_query($condbyear2, "SELECT * FROM Renal WHERE UQN='$qnumber'");

 while($retrieve=mysqli_fetch_row($find));
 {

      $question = $retrieve['question'];
      $a = $retrieve['MCQ_A']; 
       $b = $retrieve['MCQ_B'];
      $c = $retrieve['MCQ_C'];
         $d = $retrieve['MCQ_D'];
      $e = $retrieve['MCQ_E'];
     $answer = $retrieve['answer'];
       $correct = $retrieve['MCQ_correct'];


       }




      ?>


        <form action='check.php' method='POST'>  

    <table> 

  <tr><td></td><td></td></tr>
   <tr></tr>
        <tr><td><input type='radio' name='group1' value='A' /></td><td> <?php echo $a; ?></td></tr>
       <tr><td><input type='radio' name='group1' value='B' /></td><td> <?php echo $b; ?></td></tr>
         <tr><td><input type='radio' name='group1' value='C' /></td><td> <?php echo $c; ?></td></tr>
      <tr><td><input type='radio' name='group1' value='D' /></td><td> <?php echo $d; ?></td></tr>
       <tr><td><input type='radio' name='group1' value='E' /></td><td> <?php echo $e; ?></td></tr> 
   <tr>

      <?php 

     // sending the retrieved information from MYSQL via POST for use in check.php file

    $qnumber;
  $a;
   $b;
     $c;
  $d;
    $e;
  $answer;
    $correct;


   ?></tr>
         <tr><td><input type="submit" value="Submit"></td></tr>





     </table>

        </form>

1 个答案:

答案 0 :(得分:2)

1)删除while语句末尾的;

2)mysqli_fetch_row返回一个枚举数组。您需要的是关联数组,因此您应该使用mysql_fetch_assocmysqli_fetch_array代替。

while($retrieve=mysqli_fetch_assoc($find))
{
....