title: populate select box with mysql data
body: <p>I have some trouble with this.</p>
  
  <p>I have one database with the following tables:
  Countries -> All countries of the world are added
  Cities -> The cities are also added
  user_profile -> The profile of the user with the fields "country" &amp; "city".</p>
  
  <p>Everything works fine, even the populating of the boxes is working. But I don't know how to get the SELECTED value of the user for both country &amp; city.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>Select Country: &lt;br /&gt;
  &lt;select id="countries"&gt;
  &lt;option value=""&gt;--&lt;/option&gt;
  
  &lt;?php
  $sql = "SELECT country, title FROM countries ORDER BY title ASC";
  
  $rs = mysql_query($sql);
  
  while($row = mysql_fetch_array($rs))
  {
    echo "&lt;option value=\"".$row['country']."\"&gt;".$row['title']."\n  ";
  }
  ?&gt;
  &lt;/select&gt;
  
  
  Select City: &lt;br /&gt;
  &lt;select id="cities"&gt;
  &lt;option value=""&gt;Select one&lt;/option&gt;
  
  &lt;?php
  $sql = "SELECT country, title FROM cities ".
  "ORDER BY title ASC";
  
  $rs = mysql_query($sql);
  
  while($row = mysql_fetch_array($rs))
  {
    echo "&lt;option class=\"".$row['country']."\"  value=\"".$row['title']."\"&gt;".$row['title']."\n  ";
  }
  ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Now I need to check in the table user_profile which country &amp; city he chose and show it to him.</p>
  
  <p>I also use jchained (jquery plugin) to make both select boxes working together.</p>
  
  <p>How can I achieve this? If I need to post anything else, please let me know.</p>
  
  <p>Thanks in advance.</p>