title: Reverse Table rows in While Loop
body: <p>I am appending rows to a table that has pagination. My db query sorts by ASC which is what I need but the order of records should be reversed on each page. So the first page should be the newest records but that page should be ordered from oldest to newest on that page. So my table should look like this:</p>
  
  <pre><code>Page 1
  Date    Type    Registration
  -----------------------------
  9 Jan    Van       ZZASA
  14 Jan    Car      ASDFS
  19 Jan    Van      ASDFS
  
  
  Page 2
  Date    Type    Registration
  -----------------------------
  1 Jan    Van       ZZASA
  4 Jan    Bus       ASDFS
  5 Jan    Van       ASDFS
  </code></pre>
  
  <p>I am adding the rows in a WHILE loop like this:</p>
  
  <pre><code>    while($row = mysqli_fetch_assoc($result)){      
          $tablerows .= '&lt;tr&gt;
                            &lt;td&gt;'.$row['date'].'&lt;/td&gt;
                            &lt;td&gt;'.$row['type'].'&lt;/td&gt;
                            &lt;td&gt;'.$row['registration'].'&lt;/td&gt;
                         &lt;/tr&gt;
     }
  </code></pre>
  
  <p>If only I could reverse the order during the while loop it would work perfect but I am not sure how to do it. Would it work if I add each to an array and then use an array_reverse function?</p>