title: PHP Populate Dropdown From Database and then Update on Button Click
body: <p>I'm having trouble populating a dropdown list from a database and then updating the selected item on a button click. What I'm trying to have is that when you pick Option B in the dropdown, it'll update that option on the click of a submit button.</p>
  
  <p>I can get the dropdown box to populate fine, but when clicking the button it won't update correctly. I'm learning as I go, any pointers would be appreciated.</p>
  
  <pre><code>&lt;form id='filter' name='filter' method='post' action=''&gt;
  
                  &lt;?php
  
                  $getIssuedVouchers2 = "SELECT * FROM vouchercodes WHERE status = 'Active'";
                  $issuedVouchersResult2 = mysql_query($getIssuedVouchers);
  
                  ?&gt;
  
                  &lt;select&gt;
  
                      &lt;?php
  
                          while ($ivSelectRow = mysql_fetch_array($issuedVouchersResult2)) {
                              echo "&lt;option name='updatestatus'&gt;" . $ivSelectRow['vouchId'] . "&lt;/option&gt;";
                          }
  
                      ?&gt;
  
                  &lt;/select&gt;
  
                  &lt;INPUT TYPE="Submit" VALUE="Update the Record" NAME="Submit" /&gt;
  
                  &lt;?php
                      if(isset($_POST['Submit'])) { //if the submit button is clicked
  
                      $updatingQuery = "UPDATE vouchercodes SET status='Expired' WHERE vouchId = '".$ivSelectRow['vouchId']."' ";
                      mysql_query($updatingQuery) or die("Cannot update");//update or error
                      }
                  ?&gt;
  
              &lt;/form&gt;
  </code></pre>