title: php random mysql data
body: <p>I have a MySQL database with 6 columns in a table. There will eventually be about 100 rows, for now I have 3.</p>
  
  <p>Column titles: FirstName, SecondName, Sentence1, Sentence2, Sentence3, Sentence4</p>
  
  <p>All tables are set to VARCHAR</p>
  
  <p><strong>I want to use php on a web page to call random data from each row, eg mix and match row1 FirstName with row3 SecondName and row2 Sentence1 etc.</strong></p>
  
  <p>I read it is quicker to randomise using php but I really can't grasp how to do this despite searching.</p>
  
  <p>I can connect to my MySQL database and get results returned using this code:</p>
  
  <pre><code>    &lt;?php
      // Connect to database server
      mysql_connect("localhost", "xxx", "yyy") or die (mysql_error ());
      // Select database
      mysql_select_db("zzz") or die(mysql_error());
      // SQL query
      $strSQL = "SELECT * FROM Users";
      // Execute the query (the recordset $rs contains the result)
      $rs = mysql_query($strSQL);
      // Loop the recordset $rs
      // Each row will be made into an array ($row) using mysql_fetch_array
      while($row = mysql_fetch_array($rs)) {
      // Write the value of the column FirstName (which is now in the array $row)
      echo $row['FirstName'] . "&lt;br /&gt;";
        }
      // Close the database connection
      mysql_close();
      ?&gt;
  </code></pre>
  
  <p>but this just returns one column of data. I need the random code to be returned in the webpage using something like:</p>
  
  <pre><code>echo $firstname . $lastname . $sentence1 . $sentence2 . $sentence3 . $sentence4;
  </code></pre>
  
  <p>Note, this will be repeated for another 3 or 4 rows afterwards too</p>
  
  <pre><code>echo $firstname_2 . $lastname_2 . $sentence1_2 . $sentence2_2 . $sentence3_2 . $sentence4_2;
  </code></pre>
  
  <p>I'm not too hot on arrays but if someone can get me started it would be great, thanks.</p>