title: Loading data from MySQL to table horizontally
body: <p>I'm loading some data from MySQL database and it looks like this:</p>
  
  <pre><code>| Gray |  S  |
  | Gray |  M  |
  | Gray |  L  |
  | Red  |  S  |
  | Red  |  M  |
  | Red  |  L  |
  </code></pre>
  
  <p>I want to load data to my table horizontally like this, grouped by color:</p>
  
  <pre><code>| Gray |  S  |  M  |  L  |  XL  |
  | Red  |  S  |  M  |  L  |  XL  |
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;table&gt;
  &lt;?php foreach($products as $product) {?&gt;
      &lt;tr&gt;
      &lt;td&gt;&lt;?php echo $product['color'];?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $product['size'];?&gt;&lt;/td&gt;
      &lt;/tr&gt;       
  &lt;?php   }
  ?&gt;      
  &lt;/table&gt;
  </code></pre>
  
  <p>Question: how to load data to my table grouped by color per one line? Can I do this without separate MySQL query?</p>