title: MySQIi select count and order by count
body: <p>My table looks like this (this is just an example):</p>
  
  <pre><code>id    name    title    time
  ----------------------------
  1     name1   title1   1000
  2     name1   title1   1001
  3     name1   title1   1002
  4     name2   title2   1003
  5     name2   title2   1004
  6     name3   title3   1005
  7     name4   title4   1006
  8     name4   title4   1007
  9     name4   title4   1008
  10    name4   title4   1009
  </code></pre>
  
  <p>I want to write a SQL statement to select the count of each name as well as the info related to it. Time is really a UNIX timestamp, but I just changed to make simple for this question.</p>
  
  <pre><code>// This is will get me the trending posts for only the last minute
  $time_in_past = time() - 60;
  $mysqli-&gt;query(
      "SELECT COUNT(`id`) FROM `trending`........WHERE `time` &lt; '$time_in_past'"
  );
  </code></pre>
  
  <p>I want to results after fetching with <code>while()</code> statement in PHP to be like this:</p>
  
  <pre><code>name: name4 count: 4 title: title4
  name: name1 count: 3 title: title1
  name: name2 count: 2 title: title2
  name: name3 count: 1 title: title3
  </code></pre>
  
  <p>I want them to be ordered by COUNT of each one while still getting 10 results (in this example there are only 4).</p>