title: Stuck on making an array with its items from an SQL query
body: <p>Basically i wont to be able to grab all items and insert them into an array at the moment i have made Category arrays but i cant seem to get all the items in the array only one item is going into each section </p>
  
  <pre><code>$sql2 = "SELECT * FROM products group by Market ";
  $result2 = $conn-&gt;query($sql2);
  
  // GETS all Category
  $sql = "SELECT DISTINCT Category FROM products group by Category";
  
  $result = $conn-&gt;query($sql);
  
  $array = array();
  
  while ($row = $result-&gt;fetch_assoc()) {
  
      $array[$row['Category']] =  array();
  }
  
  while ($row = $result2-&gt;fetch_assoc()) {
  
      $array[$row['Category']] =  array($row['Market']);
  }
  </code></pre>
  
  <p>At the moment it outputs </p>
  
  <p><a href="https://i.stack.imgur.com/ykrb3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ykrb3.png" alt="array of my categories with one item"></a></p>
  
  <p>But there are more items for each category for example looking at the SQL there are 2 markets for camcorders, it seems to me its not looping all the sub categories or overwriting them</p>
  
  <pre><code>SELECT * FROM products where Category = 'CAMCORDERS' group by Market 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/RbnMa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RbnMa.png" alt="query of camcorders"></a></p>