title: How to display selected content of database randomly without repeating?
body: <p>I want to display the Questions from the database for online aptitude test. i generate code to display 10 question randomly.</p>
  
  <p><strong>but major problem is Question is repeating. i don't want repeated question in question paper.</strong></p>
  
  <p>here is a code for display question randomly:-</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;form action="./eval.php" method="post"&gt;
  &lt;?php
  
  $connect = mysql_connect("localhost" ,"root","");
  
  mysql_select_db("aptitude");
  
  
  
   for ( $i = 1; $i &lt; 11; ++$i )
  {
  
  $query = mysql_query("SELECT * FROM `main`  ORDER BY RAND() LIMIT 1 ");
  
  
  
  
   while($rows = mysql_fetch_array($query)):
  
      $q = $rows['Q_no'];
      $qus = $rows['Question'];
      $a = $rows['answer1'];
      $b = $rows['answer2'];
      $c = $rows['answer3'];
      $d = $rows['answer4'];
      $ans = $rows['correct'];
  
       echo "Q$i:-$qus &lt;br&gt;";
      echo "A &lt;input type=radio name = 'answer[$q]' value = '$a'&gt;&lt;/input&gt;$a &amp;nbsp &amp;nbsp"; 
      echo "B &lt;input type=radio name = 'answer[$q]' value = '$b'&gt;&lt;/input&gt;$b &amp;nbsp &amp;nbsp"; 
      echo "C &lt;input type=radio name = 'answer[$q]' value = '$c'&gt;&lt;/input&gt;$c &amp;nbsp &amp;nbsp "; 
      echo "D &lt;input type=radio name = 'answer[$q]' value = '$d'&gt;&lt;/input&gt;$d &lt;br&gt;&lt;br&gt; ";
  
  
      endwhile;
  
   }
  
  
  ?&gt;
  
  &lt;center&gt;&lt;input name="cmdSubmit" type="submit" id="cmdSubmit" value="Submit"/&gt;
  &lt;/center&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>