title: Listing Items by Category in PHP
body: <p>Can someone help me with listing items by category in PHP?</p>
  
  <p>I'm trying to create a simple list of books by category:</p>
  
  <p><strong>JavaScript</strong><br>
  JavaScript Patterns<br>
  Object-Oriented JavaScript  </p>
  
  <p><strong>Ajax</strong><br>
  Ajax Definitive Guide<br>
  Bulletproof Ajax  </p>
  
  <p><strong>jQuery</strong><br>
  jQuery Cookbook<br>
  Learning jQuery 1.3  </p>
  
  <p>I have no problems with the data structure or SQL query:</p>
  
  <pre><code>BOOK:     book_id, book_title, fk_category_id  
  CATEGORY: category_id, category_name
  
  SELECT category.category_name, book.book_title
  FROM category LEFT OUTER JOIN book
  ON category.category_id = book.fk_category_id;
  </code></pre>
  
  <p>My problem is that I don't know how to write the PHP script to list the books under each category header.</p>
  
  <p>I know enough to get the result set into an array, but then I'm stumped on using that array to group the items as shown.</p>
  
  <p>Another Stack question addresses almost the same thing, but the responses stop short of solving the PHP code: <a href="https://stackoverflow.com/questions/2217030/list-items-by-category">List items by category</a></p>
  
  <p>Thanks!</p>