Jump to content

[SOLVED] Problem with While Statement


ifis

Recommended Posts

i have a while statement in my code so I can output an array of variable lenght.  The only problem is that the page does not display in the correct order, I.E. my footer comes before the output of the while statement, any way to fix this.  Here is the php code:

sql = "SELECT * FROM  `writtenqs` ORDER BY RAND() LIMIT 3";
$result=mysql_query($sql);

echo "<form id='form1' name='form1' method='post' action='insttest2.php'>
    <table width='100%' border='1'>";
    $i=1;
    
while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td width='13%' scope='row'>$row[code]</td>";
  echo "<td width='87%'>$row[lic] </td>";
  echo " </tr>";
  echo "<tr>";
  echo "<td></td>";
  echo "<td>$row[question]</td>";
  echo "</tr>";
  echo "<tr>";
  echo "<th scope='row'> </th>
        <td>
          <p>
            <label>
              <input type='radio' name='answer'.$i value='A' id='RadioGroup1_0' />$row[oneanswer]</label>
            <br />
            <label>
              <input type='radio' name='answer'.$i value='B' id='RadioGroup1_1' />
              $row[twoanswer]</label>
            <br />
            <label>
              <input type='radio' name='answer'.$i value='C' id='RadioGroup1_2' />
              $row[threeanswer]</label>
            <br />
          <input name='question#'.$1.' type='hidden' value='$row[numquestion]' />
          </p>
        </td>
      </tr>";
      $i++;
    }
echo "<input name='Submit' type='button' value='Submit' />
</form>";
?>

 

Thanks[/code]

Link to comment
https://forums.phpfreaks.com/topic/87474-solved-problem-with-while-statement/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.