title: Count rows order by last 12 months - PHP SQL
body: <p>I'm trying to count the number of rows, column(id) in my table details and display the last 12 months - ideally this will be a rolling 12 months, so it will display the current month and the previous 11. I have the following but it returns nothing:</p>
  
  <pre><code>    $sql = "SELECT DATE_FORMAT(date, '%m') as 'month',
  COUNT(id) as 'total'
  FROM details
  GROUP BY DATE_FORMAT(date, '%m')
  ";
  $result = mysql_query($sql, $con);
  
  if (!$result) {
      echo "DB Error, could not query the database\n";
      echo 'MySQL Error: ' . mysql_error();
      exit;
  }
  
  while ($row = mysql_fetch_assoc($result)) {
      $row['month']. " = " .$row['total']. "&lt;br /&gt;";
      }
  </code></pre>
  
  <p>I hope I have explained myself, if not please ask me...</p>
  
  <p>Thanks for looking.</p>
  
  <p>B.</p>