title: PHP - return SQL GROUP BY as array?
body: <p>I'm trying to return a MySQL query using <code>GROUP BY</code> as a array.</p>
  
  <p>My table looks like this:</p>
  
  <pre><code>user_id | type
  --------------------
  1       | test
  1       | test
  2       | test
  1       | hello
  1       | helloworld
  </code></pre>
  
  <p>And my code and query:</p>
  
  <pre><code>$number_of_workouts = array();
  $query = mysqli_query(connect(),"SELECT type, COUNT(*) FROM `log` WHERE `user_id` = $user_id GROUP BY type");
  $number_of_workouts = mysqli_fetch_assoc($query);
  
  return $number_of_workouts;
  </code></pre>
  
  <p>This code above isn't returning a array with all types listed, it will only return the number of one type(assuming that <code>$user_id = 1</code>.</p>
  
  <p>How can I return the result of the query as an array?</p>