The php code below, outputs a drop down / select menu in php.
| PHP Code: |
<?php
echo "<select name=\"ud_county\">";
// foreach example - loop through each entry in an array
$ukcounties = array("Aberdeenshire"," Anglesey"," Angus"," Antrim"," Argyllshire"," Armagh"," Ayrshire"," Banffshire"," Bedfordshire"," Berkshire"," Berwickshire"," Brecknockshire"," Buckinghamshire"," Buteshire"," Caernarfonshire"," Caithness"," Cambridgeshire"," Cardiganshire"," Carmarthenshire"," Cheshire"," Clackmannanshire"," Cornwall"," Cromartyshire"," Cumberland"," Denbighshire"," Derbyshire"," Devon"," Dorset"," Down"," Dumfriesshire"," Dunbartonshire"," Durham"," East Lothian"," Essex"," Fermanagh"," Fife"," Flintshire"," Glamorgan"," Gloucestershire"," Hampshire"," Herefordshire"," Hertfordshire"," Huntingdonshire"," Inverness-shire"," Kent"," Kincardineshire"," Kinross"," Kirkcudbrightshire"," Lanarkshire"," Lancashire"," Leicestershire"," Lincolnshire"," Londonderry"," Merioneth"," Middlesex"," Midlothian"," Monmouthshire"," Montgomeryshire"," Morayshire"," Nairnshire"," Norfolk"," Northamptonshire"," Northumberland"," Nottinghamshire"," Orkney"," Oxfordshire"," Pembrokeshire"," Peeblesshire"," Perthshire"," Radnorshire"," Renfrewshire"," Ross-shire"," Roxburghshire"," Rutland"," Selkirkshire"," Shetland"," Shropshire"," Somerset"," Staffordshire"," Stirlingshire"," Suffolk"," Surrey"," Sussex"," Sutherland"," Tyrone"," Warwickshire"," West Lothian"," Westmorland"," Wigtownshire"," Wiltshire"," Worcestershire"," Yorkshire");
foreach ( $ukcounties AS $elements )
{
print "<option value=\". $elements .\">". $elements ."</option>;/n";
}
echo "</select>";
?> |
The same list in regular html would require the following HTML code. As you can see below, there is a lot of code here, for something quite simple.
| PHP Code: |
<select name="county">
<option>Aberdeenshire</option>
<option>Anglesey</option>
<option>Angus</option>
<option>Antrim</option>
<option>Argyllshire</option>
<option>Armagh</option>
<option>Ayrshire</option>
<option>Banffshire</option>
<option>Bedfordshire</option>
<option>Berkshire</option>
<option>Berwickshire</option>
<option>Brecknockshire</option>
<option>Buckinghamshire</option>
<option>Buteshire</option>
<option>Caernarfonshire</option>
<option>Caithness</option>
<option>Cambridgeshire</option>
<option>Cardiganshire</option>
<option>Carmarthenshire</option>
<option>Cheshire</option>
<option>Clackmannanshire</option>
<option>Cornwall</option>
<option>Cromartyshire</option>
<option>Cumberland</option>
<option>Denbighshire</option>
<option>Derbyshire</option>
<option>Devon</option>
<option>Dorset</option>
<option>Down</option>
<option>Dumfriesshire</option>
<option>Dunbartonshire</option>
<option>Durham</option>
<option>East Lothian</option>
<option>Essex</option>
<option>Fermanagh</option>
<option>Fife</option>
<option>Flintshire</option>
<option>Glamorgan</option>
<option>Gloucestershire</option>
<option>Hampshire</option>
<option>Herefordshire</option>
<option>Hertfordshire</option>
<option>Huntingdonshire</option>
<option>Inverness-shire</option>
<option>Kent</option>
<option>Kincardineshire</option>
<option>Kinross</option>
<option>Kirkcudbrightshire</option>
<option>Lanarkshire</option>
<option>Lancashire</option>
<option>Leicestershire</option>
<option>Lincolnshire</option>
<option>Londonderry</option>
<option>Merioneth</option>
<option>Middlesex</option>
<option>Midlothian</option>
<option>Monmouthshire</option>
<option>Montgomeryshire</option>
<option>Morayshire</option>
<option>Nairnshire</option>
<option>Norfolk</option>
<option>Northamptonshire</option>
<option>Northumberland</option>
<option>Nottinghamshire</option>
<option>Orkney</option>
<option>Oxfordshire</option>
<option>Pembrokeshire</option>
<option>Peeblesshire</option>
<option>Perthshire</option>
<option>Radnorshire</option>
<option>Renfrewshire</option>
<option>Ross-shire</option>
<option>Roxburghshire</option>
<option>Rutland</option>
<option>Selkirkshire</option>
<option>Shetland</option>
<option>Shropshire</option>
<option>Somerset</option>
<option>Staffordshire</option>
<option>Stirlingshire</option>
<option>Suffolk</option>
<option>Surrey</option>
<option>Sussex</option>
<option>Sutherland</option>
<option>Tyrone</option>
<option>Warwickshire</option>
<option>West Lothian</option>
<option>Westmorland</option>
<option>Wigtownshire</option>
<option>Wiltshire</option>
<option>Worcestershire</option>
<option>Yorkshire</option>
</select> |
Please visit http://www.ilovejackdaniels.com/resources/uk-counties-select-box/ for more information on drop down menus. |