title: Populating a select dropdown with a database value PHP
body: <p>I am trying to find a clear answer for populating a select option drop down menu with a value from a database. I have found various answers including this one which I thought was what I needed but turned out to not be the case.</p>
  
  <p><a href="https://stackoverflow.com/questions/18733545/selected-value-get-from-db-into-dropdown-select-box-option-using-php-mysql-error">selected value get from db into dropdown select box option using php mysql error</a></p>
  
  <p>As described in the previous post my question looks like so. I have a form that is populated with all the database values of a current listing. I can get everything to echo correctly except what the user previously selected under status. </p>
  
  <p>A snippet of my form is as follows. MLS # echos back from the saved variable $listingMLS just fine and populates the form perfectly however when I echo $listingStatus which returns the correct value of the current listing it does not update the selected option. </p>
  
  <p>I am sure there is something I am missing and will provide any further descriptions needed. I hope I conveyed this clearly. </p>
  
  <pre><code>&lt;div class="row"&gt;
      &lt;div class="col-md-2"&gt;&lt;/div&gt;
      &lt;div class="col-md-8"&gt;
  MLS #
  &lt;input type="text" maxlength="100" class="form-control" name="listingMLS" value="&lt;?php echo $listingMLS; ?&gt;"&gt;
      &lt;/div&gt;
      &lt;div class="col-md-2"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;br&gt;
  
  &lt;div class="row"&gt;
      &lt;div class="col-md-2"&gt;&lt;/div&gt;
      &lt;div class="col-md-8"&gt;
  Status
  &lt;select class='form-control' name='listingStatus' value="&lt;?php echo $listingStatus; ?&gt;"&gt;
  &lt;option value='0' selected&gt;Active&lt;/option&gt;
  &lt;option value='1' selected&gt;Price Reduced&lt;/option&gt;
  &lt;option value='2' selected&gt;Sold&lt;/option&gt;
  &lt;option value='3' selected&gt;Archived&lt;/option&gt;
  &lt;/select&gt;
      &lt;/div&gt;
      &lt;div class="col-md-2"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Thank you for any help. </p>