title: php mutiselect dropdown which get data from mysql
body: <p>I would like to create a multi-select drop down list of countries in my form which lets users choose more than one country and also provides the ability to remove the item they selected, if needed.</p>
  
  <p>I could create a drop down list which extracts the name of the countries from a mysql table, but it lets users only select one country. I searched a lot for multi-select drop down but none of the samples that I have found get data from mysql. They had only a few options which could easily write with option value like <a href="https://stackoverflow.com/questions/13455715/how-to-access-the-values-selected-in-the-multiselect-dropdown-list-in-php">How to access the values selected in the multiselect dropdown list in PHP?</a></p>
  
  <p>This is my code through which only one item can be selected:</p>
  
  <pre><code>&lt;?php
  mysql_connect('localhost', 'root', 'password');
  mysql_select_db('imdb');
  
  $sql2 = "SELECT country FROM countries";
  $result2 = mysql_query($sql2);
  
  echo "&lt;select name='country'&gt;";
  while ($row = mysql_fetch_array($result2)) {
      echo "&lt;option value='" . $row['country'] . "'&gt;" . $row['country'] . "&lt;/option&gt;";
  }
  echo "&lt;/select&gt;";
  ?&gt;
  </code></pre>