title: How to sort SQL query results if value is the same?
body: <p>I have a table (items) in my DB and it looks like this:</p>
  
  <pre><code> --------------------------------------
  | id | name | price | buyer | status   |
   --------------------------------------
  | 1    item1    10     Bob   requested |
  | 2    item2    20     Bob   requested |
  | 3    item3    10     Tom   requested |
   --------------------------------------
  </code></pre>
  
  <p>I'm trying to query the data and then sort it, lump it together, and display it by name. If 2 names are the same it'll group it into one div in my HTML, and if they are different it'll group it into a different div. Basically each group of names is its own div whether there is 0 or 20 names that are the same. So far I queried my data like so</p>
  
  <pre><code>$request_data_query = $db-&gt;prepare("SELECT * FROM items WHERE status = 'requested' GROUP BY buyer");
  $request_data_query-&gt;execute();
  
  while($fetch = $request_data_query-&gt;fetch(PDO::FETCH_ASSOC)) {
  </code></pre>
  
  <p>then I was trying to compare results to see if they match </p>
  
  <pre><code>    if ($fetch['buyer'] === $fetch['buyer']) {
          //Same name HTML code here
      } else {
         // Single person HTML
      }
  }
  </code></pre>
  
  <p>That code isn't sorting the way I thought it would. That prints 2 separate divs for the duplicate name and doesn't print the single person. I'm not quite sure what else to do.</p>