title: display each category with their items from table in select option
body: <p>I've one table <strong>products_tbl</strong> </p>
  
  <pre><code>+----------+-----------+---------------+
  |product_id|ProductName|ProductCategory|
  +----------+-----------+---------------+
  |1         |Apple      |fruits         |
  |2         |Orange     |fruits         |
  |3         |Iphone X   |Electronics    |
  |4         |FJ-Eye Lens|Accessories    |
  +----------+-----------+---------------+
  </code></pre>
  
  <p>i want to display each categories items in separated group using <strong>HTML SELECT OPTION</strong></p>
  
  <p><strong>products.php</strong></p>
  
  <pre><code>$productQ = "SELECT * FROM products_tbl ";
  try { 
      $stmt2 = $db-&gt;prepare($productQ); 
      $stmt2-&gt;execute();
  } catch(PDOException $ex) {   
      die("Failed to run Query: " . $ex-&gt;getMessage()); 
  } 
  
  $produtsrows = $stmt2-&gt;fetchAll(); 
  
  echo"&lt;select&gt;";
  foreach($produtsrows as $prow): 
      echo "&lt;optgroup label=".$prow['ProductCategory']."&gt;";
      echo"   &lt;option&gt;".$prow['ProductName']."&lt;/option&gt;
            &lt;/optgroup&gt;";
  endforeach;
  echo "
      &lt;/select&gt;
      ";
  </code></pre>
  
  <p>it display it like so</p>
  
  <pre><code>fruits
  Apple 
  fruits
  Orange  
  Electronics    
  Iphone X
  Accessories    
  FJ-Eye Lens
  </code></pre>