Using PHP to generate random data
<p>I am developing an application that has a question bank through which i want to generate a question paper randomly. I am using PHP and HTML. I am using html as my front end and for back end PHP. I have developed the code but there is a problem with it, its generating 4 textarea 2 for one question and i am unable to debug it</p>

<pre><code>&lt;?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "rgpv";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn-&gt;connect_error) {
    die("Connection failed: " . $conn-&gt;connect_error);
}

$sql = "SELECT ques FROM bank WHERE sub='$_POST[sub]' ORDER BY RAND() LIMIT 2";
$result = $conn-&gt;query($sql);


$result = $conn-&gt;query($sql);

    // output data of each row
    while($row = $result-&gt;fetch_assoc()) {


        ?&gt;

&lt;!DOCTYPE html&gt;
&lt;html &gt;
  &lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;title&gt;Login Form&lt;/title&gt;

      &lt;!-- Calling CSS --&gt;
      &lt;link rel="stylesheet" href="css/reset.css"&gt;
      &lt;link rel='stylesheet prefetch' href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900|RobotoDraft:400,100,300,500,700,900'&gt;

      &lt;!--File for fonts--&gt;
      &lt;link rel='stylesheet prefetch' href='css/bootstrap.css'&gt;
      &lt;link rel='stylesheet prefetch' href='css/font-awesome.min.css'&gt;
      &lt;link rel="stylesheet" href="css/style.css"&gt;
  &lt;/head&gt; &lt;!-- end Head --&gt;

  &lt;body background="images/journal.jpg"&gt;
    &lt;!-- Mixins--&gt;
      &lt;!-- Form Title--&gt;
    &lt;div class="pen-title"&gt;
      &lt;h1&gt;University Institute of Technology- RGPV&lt;/h1&gt;&lt;h2&gt;Random Question Paper Generator Portal&lt;/h2&gt;
&lt;/div&gt;


       &lt;fieldset class="form-group"&gt;
    &lt;label for="exampleTextarea"&gt;Question 1&lt;/label&gt;
    &lt;textarea class="form-control txt" id="name" rows="3" value="" disabled&gt;&lt;?php echo $row["ques"]; ?&gt;&lt;/textarea&gt;
  &lt;/fieldset&gt;


       &lt;fieldset class="form-group"&gt;
    &lt;label for="exampleTextarea"&gt;Question 2&lt;/label&gt;
    &lt;textarea class="form-control txt" id="name" rows="3" value="" disabled&gt;&lt;?php echo $row["ques"]; ?&gt;&lt;/textarea&gt;
  &lt;/fieldset&gt;


    &lt;/body&gt;
&lt;/html&gt;

&lt;?php

}

?&gt;     
</code></pre>