title: MySql Query/PHP to get all column value with same customer name
body: <p>I'm not really sure how to word my problem for the title but here's what i'm trying to do. I have a table:</p>
  
  <p>table1</p>
  
  <pre><code>-----------------------------------
  | customer |   phone  | productid |
  -----------------------------------
  |   John   | 123-4567 |  P123     |
  -----------------------------------
  |   Bam    | 345-6789 |  P033     |
  -----------------------------------
  |   John   | 123-4567 |  P432     |
  -----------------------------------
  |   Gin   | 444-1234 |  P543     |
  -----------------------------------
  |   Bam    | 345-6789 |  P320     |
  -----------------------------------
  |   Bam    | 345-6789 |  P675     |
  -----------------------------------
  </code></pre>
  
  <p>And I'm trying to get a result like this:</p>
  
  <p><strong>Customer:</strong> John 
  <strong>Phone :</strong> 123-4567
  <strong>Products:</strong> P123, P432</p>
  
  <p><strong>Customer:</strong> Bam
  <strong>Phone:</strong> 345-6789
  <strong>Products:</strong> P033, P320, P675</p>
  
  <p><strong>Customer:</strong> Gin
  <strong>Phone:</strong> 444-1234
  <strong>Products:</strong> P543</p>
  
  <p>I'm not sure if there's a mysql query that would allow me to get this result but I did try to do it on PHP and didn't know where to start. Below is the php code that i'm currently using:</p>
  
  <pre><code>$sql = "SELECT * FROM table1 ORDER BY user";
  $result = mysql_query($sql);
  
  while ($row = mysql_fetch_array($result)) {
  
      echo '&lt;/br&gt;Customer: '.$row['customer'].'&lt;/br&gt;Phone: '.$row['phone'].'&lt;/br&gt;Products: '.$row['productid'].'&lt;/br&gt;';
  }
  </code></pre>
  
  <p>I know that i need to add a code inside the while statements that would do "while it's the same user, concatenate productid in to a variable" but I just can't translate it into codes.</p>
  
  <p>Hope this makes sense. Thanks in advance!</p>