title: PHP & MYSQL: using group by for categories
body: <p>My database has the following setup</p>
  
  <pre><code>productid | productname | category id
  </code></pre>
  
  <p>and I want to output them like so:</p>
  
  <pre><code>category #1
  item 1 
  item 2
  item 3
  
  category #2
  item 1 
  item 2
  item 3
  </code></pre>
  
  <p>I used group by the group them together and that works fine, but I want to loop through each group and display the contents of that group. How would I do this? </p>