This code compiles an ordered dropdown list of all countries. Please read the
Country Dropdown example first if you need more specific instructions.
The GeoNames Country Info service allways returns the list ordered by Country Code. This code example shows how to make the API sort the results for you by Country Name:
<?php
$options = array(
'sortby' => 'countryname',
);
$result = geonames_query('countryinfo', NULL, $options);
foreach ($result->results as $country) {
$optionlist .= sprintf('<option value="%s">%s</option>', $country['countrycode'], $country['countryname']);
}
?>
<form>
<select><? print $optionlist ?></select>
</form>
Recent Comments
23 weeks 2 days ago
30 weeks 1 day ago
1 year 18 weeks ago
2 years 8 weeks ago
2 years 12 weeks ago
2 years 12 weeks ago
2 years 32 weeks ago
2 years 38 weeks ago
2 years 38 weeks ago
2 years 40 weeks ago