Hey,
I'm trying to create a drop-down select box for my users to select their country on my site...
The country list is stored in one record with a line break between each country, ie,
Afghanistan
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antigua & Barbuda
etc...
I'm using this code to get the countries from the database...
$countrySQL = mysql_query("SELECT content FROM components WHERE name = 'country_list'");
$result = mysql_fetch_array($countrySQL);
$countries = $result['content'];
$option_country = ereg_replace("\n","<br>",$countries);
echo ("$option_country");
the output is as follows:
Afghanistan
<br>Albania
<br>Algeria
<br>American Samoa
<br>Andorra
<br>Angola
<br>Anguilla
<br>Antigua & Barbuda
etc...
How do I get php to format this to display select options... ie,
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Antigua & Barbuda">Antigua & Barbuda</option>
etc....
Thanks for any help. Looking forward to a solution 🙂
Rob