title: Comparing the selected values of radio button generated dynamically through while loop and displaying score
body: <p>I am creating an exam page using php and mysql as database. I am displaying the questions and options through while loop.</p>
  
  <p>The problem I am facing is to get the selected value from the user.</p>
  
  <p>Any help would be appreciated!</p>
  
  <p>Here is the code :</p>
  
  <pre><code>&lt;body&gt;
  &lt;form name="form1" method="POST" action=""&gt;
  &lt;input name="submit" type="submit" value="Start Test"&gt;
  
  &lt;?php
  $username="root";
  $password="";
  $database="assesment";
  mysql_connect("localhost",$username,$password);
      @mysql_select_db($database) or die( "Unable to select database");
  
      if(isset($_POST['submit']))
  {   
      $query = "SELECT * FROM demo";
      $result = mysql_query($query);
      $num = mysql_num_rows($result);
      mysql_close();
      echo "&lt;b&gt;&lt;center&gt;Database Output&lt;/center&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;";
      $i=0;while ($i &lt; $num)
      {
          $qno = mysql_result($result,$i,"qno");
          $quest = mysql_result($result,$i,"quest");
          $a = mysql_result($result,$i,"a");
          $b = mysql_result($result,$i,"b");
          $c = mysql_result($result,$i,"c");
          $d = mysql_result($result,$i,"d");
          echo "
          &lt;br&gt;&lt;br&gt;&lt;b&gt; $qno.&amp;nbsp;&amp;nbsp;$quest&lt;br&gt;&lt;br&gt; 
          Options : &lt;/b&gt;
          &lt;input type='Radio' Name='Answer $qno' value='A'  &gt;A.&lt;span&gt;&lt;span&gt; $a &amp;nbsp;&amp;nbsp;
          &lt;input type='Radio' Name='Answer $qno' value='B'  &gt;B.&lt;span&gt;&lt;span&gt; $b &amp;nbsp;&amp;nbsp;
          &lt;input type='Radio' Name='Answer $qno' value='C'  &gt;C.&lt;span&gt;&lt;span&gt; $c &amp;nbsp;&amp;nbsp;
          &lt;input type='Radio' Name='Answer $qno' value='D'  &gt;D.&lt;span&gt;&lt;span&gt; $d &amp;nbsp;&amp;nbsp; 
          &lt;br&gt;&lt;br&gt;";
          $i++;
      }
  }
  </code></pre>