Hi everone, I have the code below which displays all the counties in Ireland in a <select> box...it works OK.
How can I turn this block of code into a function so that I can call it from anywhere without repeating the block of code.
Thanks for any help
<?
$products_selected = $HTTP_POST_VARS['query'];
$result = mysql_query ("SELECT county FROM counties ORDER BY countyid
ASC");
print "<select class=\"bginput\" name=\"query\">";
print "<option value=1>All Counties</option>";
while ($a_row = mysql_fetch_row ($result)) {
foreach ($a_row as $query)
if ($query == $products_selected) $sel =
'selected="selected"';
else $sel = "";
print "<option value=\"$query\" $sel> $query ";
}
print "</select><input type=submit name=\"submit\">";
?>