title: php quiz having questions and answers in two different resultset
body: <p>I am making a quiz which have questions and its options. Both questions and options are coming from database in resultsets. I am facing problems in loops and resultsets. </p>
  
  <p>1 - I am not able to choose option out of each question. Whenever, I am selecting option from Question 1, I couldn't select option from Question 2.</p>
  
  <p>2 - My page is reloading equals to the number of questions are in the quiz. As for example, I have two questions in quiz then page is reloading twice, if there are 5 questions then its reloading 5 times.</p>
  
  <pre><code>if(@$_GET['q']== 'quiz' &amp;&amp; @$_GET['step']== 2) {
  $eid=@$_GET['eid'];
  $sn=@$_GET['n'];
  $total=@$_GET['t'];
  $a=1;
  $b=0;
  $q=mysqli_query($con,"SELECT count(*) FROM questions WHERE eid='$eid'" );
  while($row=mysqli_fetch_array($q) ){
      $b=$row['count(*)'];
  }
  echo '&lt;div class="panel" style="margin:5%"&gt;';
  for($a=1;$a&lt;=$b;$a++){
  $q=mysqli_query($con,"SELECT * FROM questions WHERE eid='$eid' AND sn='$a' " );
  while($row=mysqli_fetch_array($q) )
  {
  $qns=$row['qns'];
  $qid=$row['qid'];
  echo '&lt;b&gt;Question &amp;nbsp;'.$a.'&amp;nbsp;:&lt;br /&gt;'.$qns.'&lt;/b&gt;&lt;br /&gt;';
  $q=mysqli_query($con,"SELECT * FROM options WHERE qid='$qid' " );
  echo '&lt;form action="update.php?q=quiz&amp;step=2&amp;eid='.$eid.'&amp;n='.$sn.'&amp;t='.$total.'&amp;qid='.$qid.'" method="POST"  class="form-horizontal"&gt;
  &lt;br /&gt;';
  while($row=mysqli_fetch_array($q) )
  {
  $option=$row['option'];
  $optionid=$row['optionid'];
  echo'&lt;input type="radio" name="ans" value="'.$optionid.'"&gt;'.$option.'&lt;br /&gt;';
  }
  echo '&lt;br /&gt;&lt;br /&gt;';
  }
  }
  echo'&lt;br /&gt;&lt;button type="submit" class="btn btn-primary"&gt;&lt;span class="glyphicon glyphicon-lock" aria-hidden="true"&gt;&lt;/span&gt;&amp;nbsp;Submit&lt;/button&gt;&lt;/form&gt;&lt;/div&gt;';
  }
  </code></pre>
  
  <p>Thanks for helping. </p>