title: showing selected option from mysql in dropdown
body: <p>I have a dropdown showing options from mysql, no problem there.  The problem is on the update page when i want to show the option already selected previously.</p>
  
  <p>The dropdown selects options from the margins table and puts the value into a field in the products table.</p>
  
  <p>This is the query that selects the product record :</p>
  
  <pre><code>&lt;?php
  $recordID = $_GET["recordID"];
  $product_result = mysqli_query($con,"SELECT * FROM products WHERE product_code='$recordID'") or die(mysqli_error($con)); 
  $product = mysqli_fetch_array($product_result);
  $checked_special = $product['product_special'];
  $checked_publish = $product['product_publish'];
  $checked_frontpage = $product['product_display_frontpage'];
  $checked_facebook = $product['display_facebook'];
  
    {
      ?&gt;  
  </code></pre>
  
  <p>And this is the part of the form that gets the options from the margins table and displays them on page.</p>
  
  <pre><code>&lt;tr&gt;
  &lt;td&gt;Display Facebook&lt;/td&gt;
  &lt;td&gt;&lt;input type="checkbox" name="display_facebook" id="display_facebook" value="y" &lt;?php if ($checked_facebook == 'y') echo 'checked'; ?&gt; /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;strong&gt;Margin Group :&lt;/strong&gt;&lt;/td&gt;
  
  &lt;td&gt; 
  &lt;select name="margin_group" id="margin_group"&gt;&lt;?php 
  $resul2 = mysqli_query($con,"SELECT * FROM margins");
  while($row2 = mysqli_fetch_array($resul2))
    {
   ?&gt; &lt;option value="&lt;?php echo $row2['margin_group']; ?&gt;"&gt; &lt;?php echo $row2['margin_group']; ?&gt;&lt;/option&gt;
      &lt;?php }  ?&gt;   &lt;/select&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>How can i get the $product['margin_group'] value from the products table show as selected option in the dropdown, so that the user doesn't have to reselect every time they update the page.</p>
  
  <p>Thanks :)</p>
  
  <p>MsKazza</p>