title: Set PHP variable from selected <option> in dropdown
body: <p>I have an index.php that contains two <code>&lt;select&gt;</code> dropdowns, both of which are populated from the MySQL database by functions in a functions.php file that is included into the index file.</p>
  
  <p>The first box is populated like so:</p>
  
  <pre><code>function getCities() {
      $query = "SELECT DISTINCT city FROM nights";
      $result = mysql_query($query);
      $items = array();
  
      if($result &amp;&amp; mysql_num_rows($result) &gt; 0) { 
          while ($row = mysql_fetch_array($result)) { 
              $items[] = array( $row[0], $row[1] ); 
              echo "&lt;option value='" . $row['city'] . "'&gt;" . $row['city'] . "&lt;/option&gt;";
          }         
      }
  }
  </code></pre>
  
  <p>What I want to do is set either the value of the selected <code>&lt;option&gt;</code> (for my present purposes, there is only one <code>&lt;option&gt;</code> in the dropdown) or its name/ID as a PHP variable so it can be used elsewhere. I've tried using <code>$row['city']</code> and putting the second function inside the while loop but that didn't work.</p>