title: Separate MySQL query results by month
body: <p><strong>The situation</strong></p>
  
  <p>I have a MySQL Database Table with many dates in it.</p>
  
  <p>Now I need to create a table from this tableentries which should look like this:</p>
  
  <pre><code>May        |          |
  22.05.2014 | Person 1 | Person 2
  23.05.2014 | Person 1 | Person 2
  
  June       |          |
  02.06.2014 | Person 1 | Person 2
  25.06.2014 | Person 1 | Person 2
  </code></pre>
  
  <p>etc..</p>
  
  <p><strong>The code</strong></p>
  
  <p>I am now trying to create a loop through all my query results to do so. And right there I stuck.</p>
  
  <p>I am having something like this:</p>
  
  <p>In the "while" (fetch assoc) loop I have this:</p>
  
  <pre><code>while ($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC)) {
    $date = $row['pp_date'];
    $month = date('m', strtotime($date));
  
    $entryarray = array();
  
  }
  </code></pre>
  
  <p>You can see, that I first save the month of the date into the array. And now I don't know, how to create the array to hold all rows for each month in the array to finally output the result into the table.</p>