title: Populating drop-down list with PHP not working
body: <p>I am trying to get a drop-down list populated with PHP to my website but it is not displaying anything. It's empty <a href="https://i.stack.imgur.com/JpkIi.png" rel="nofollow noreferrer">as shown in this image</a>. Under the state it shows nothing.</p>
  
  <p>Please help me to get some details from my database results.</p>
  
  <p>My code is:</p>
  
  <pre><code>&lt;?php
  $con=mysql_connect('localhost', '', '')or die("Failed to connect to MySQL: " . mysql_error());
  $db=mysql_select_db('')or die("Failed to connect to MySQL: " . mysql_error());
  ?&gt;
  
  &lt;form&gt;
      &lt;div class="form-group"&gt;        
          &lt;div class="form-control-small"&gt;
              &lt;select id="search_status" name="state" data-placeholder="State"&gt;
                  &lt;option value=""&gt; &lt;/option&gt;
                  &lt;?php
                      $dd_res=mysql_query("Select DISTINCT state from MyTable");
                      while($row=mysql_fetch_row($dd_res))
                      { 
                          echo "&lt;option value='$row[state]'&gt; $row[state] &lt;/option&gt;";
                      }
                  ?&gt;          
              &lt;/select&gt;
          &lt;/div&gt;
  
          &lt;div class="form-control-small"&gt;
              &lt;select id="search_bedrooms" name="dist" data-placeholder="District"&gt;
                  &lt;option value=""&gt; &lt;/option&gt;
                      &lt;?php
                          $dd_res=mysql_query("Select DISTINCT dist from MyTable");
                          while($r=mysql_fetch_row($dd_res))
                          { 
                              echo "&lt;option value='$row[dist]'&gt; $row[dist] &lt;/option&gt;";
                          }
                      ?&gt;
              &lt;/select&gt;
          &lt;/div&gt;
  
          &lt;div&gt;
              &lt;button type="submit" class="btn btn-fullcolor"&gt;Search&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>