title: PHP not showing updated values in Dropdown list after submitting
body: <p>I have a dropdown list which is populated by php.I need to enter new values to the db using the data entered.The page is posted to itself.But the list does not show the new values inserted.</p>
  
  <p><strong>SOURCE CODE</strong>: </p>
  
  <pre><code>  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
      &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;title&gt;Add Product Category&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="view.css" media="all"&gt;
      &lt;script type="text/javascript" src="view.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
      function validateForm() {
          var x = document.forms["form_974780"]["productname"].value;
          if (x == null || x == "") {
              alert("Please Enter New Product Name");
              return false;
          }
      }
      &lt;/script&gt;
      &lt;/head&gt;
      &lt;body id="main_body" &gt;
  
          &lt;img id="top" src="top.png" alt=""&gt;
          &lt;div id="form_container"&gt;
  
              &lt;h1&gt;&lt;a&gt;Add Product Category&lt;/a&gt;&lt;/h1&gt;
              &lt;form id="form_974780" class="appnitro"  method="post" action="?" onsubmit="return validateForm()"&gt;
                          &lt;div class="form_description"&gt;
                  &lt;h2&gt;Add Product Category&lt;/h2&gt;
                  &lt;p&gt;&lt;/p&gt;
              &lt;/div&gt;                      
                  &lt;ul &gt;
  
                          &lt;li id="li_12" &gt;
              &lt;label class="description" for="element_12"&gt;Existing Product Categories  &lt;/label&gt;
              &lt;div&gt;
              &lt;select class="element select medium" id="element_12" name="element_12"&gt; 
              &lt;?php 
  
     // $conn = goes here 
      $result=$conn-&gt;query("SELECT pname FROM products");
      while ($row=mysqli_fetch_array($result,MYSQLI_ASSOC)){
      echo "&lt;option value='".$row['pname']."'&gt;".$row['pname']."&lt;/option&gt;";
  
  
      }
       mysqli_close($conn);
      ?&gt; 
  
              &lt;/select&gt;
              &lt;/div&gt; 
              &lt;/li&gt;       &lt;li id="li_13" &gt;
              &lt;label class="description" for="element_13"&gt;Add New Category &lt;/label&gt;
              &lt;div&gt;
                  &lt;input id="element_13" name="productname" class="element text medium" type="text" maxlength="255" value=""/&gt; 
              &lt;/div&gt;&lt;p class="guidelines" id="guide_13"&gt;&lt;small&gt;Enter the new Product Category to add and Click the Add Button. &lt;/small&gt;&lt;/p&gt; 
              &lt;/li&gt;
  
                          &lt;li class="buttons"&gt;
                      &lt;input type="hidden" name="form_id" value="974780" /&gt;
  
                      &lt;input id="saveForm" class="button_text" type="submit" name="submit" value="submit"/&gt;
              &lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/form&gt; 
  
          &lt;/div&gt;
          &lt;img id="bottom" src="bottom.png" alt=""&gt;
          &lt;/body&gt;
      &lt;/html&gt;
      &lt;?php
      if (isset($_POST['submit']))
      {
          $productname=$_POST['productname'];
          //$conn string will go here 
         $result=$conn-&gt;query("INSERT INTO products(pname)VALUES('$productname')");
          if($result)
          {
  
                      echo "&lt;font color=\"white\"&gt;";
              echo("Successfully Inserted new Products");
  
              echo"&lt;/font&gt;!";
          }
          else
          {
              echo "&lt;font color=\"red\"&gt;";
              echo("Error when inserting");
              echo"&lt;/font&gt;!";
          }
      } 
      else
      {
  
      }
      ?&gt;
  </code></pre>