title: Shuffle output row items from MYSQL database
body: <p>I have a database table with the following fields and an example:</p>
  
  <pre><code>QuestionID
  Question
  AnswerA
  AnswerB
  AnswerC
  AnswerD
  CorrectAnswer
  </code></pre>
  
  <p>Example:</p>
  
  <pre><code>QuestionID: 1
  Question: What is 2 + 2?
  AnswerA: 1
  AnswerB: 2
  AnswerC: 3
  AnswerD: 4
  CorrectAnswer: 4
  </code></pre>
  
  <p>If my database has say 20 questions, how would I get it so that not only do the questions appear in a random order but the answers appear on different radio buttons (To prevent the user from memorizing the location of the correct answer). This is to be integrated into a Facebook app. Below is my SQL query:</p>
  
  <pre><code>$sql="SELECT DISTINCT Question, QuestionID, AnswerA, AnswerB, AnswerC, AnswerD FROM miniproj ORDER BY rand() LIMIT 1";
  </code></pre>
  
  <p>This is the <code>while</code> statement I am using (I understand <code>mysql_fetch_array</code> is deprecated but I can sort that another time):</p>
  
  <pre><code>while ($myrow = mysql_fetch_array($result))
          {
              $answers = array($myrow['AnswerA'], $myrow['AnswerB'], $myrow['AnswerC'], $myrow['AnswerD']);
              shuffle($answers);
              echo("&lt;form action='question.php' method='POST'&gt;\n");
              echo("&lt;h1&gt;");
              echo("Q: ");
              echo($myrow['Question']);
              echo("&lt;/h1&gt;");
              echo("&lt;input type='radio' name='comments' value='A'&gt;\n");
              echo($myrow['AnswerA']);
              echo("&lt;p&gt;");
              echo("&lt;input type='radio' name='comments' value='B'&gt;\n");
              echo($myrow['AnswerB']);
              echo("&lt;p&gt;");
              echo("&lt;input type='radio' name='comments' value='C'&gt;\n");
              echo($myrow['AnswerC']);
              echo("&lt;p&gt;");
              echo("&lt;input type='radio' name='comments' value='D'&gt;\n");
              echo($myrow['AnswerD']);
              echo("&lt;p&gt;");
              echo("&lt;br /&gt;");
              echo("&lt;input type='submit' value='Submit'&gt;\n");
              echo("&lt;/form&gt;\n");
          }
  </code></pre>
  
  <p>Any tips would be great</p>