getMessage()); } /**** Perform queries ****/ $counties = get_geo_list($db,'counties'); $cities = get_geo_list($db,'cities'); /**** HTML select options ****/ $county_opts = select_options($counties,'name'); $city_opts = select_options($cities,'name'); /**** Message to display by default ****/ $message = "Choose your city or county below to find out which DEQ region you're in."; $msgclass = "info"; /**** Form processing ****/ if (@$_GET['type'] && @$_GET[$_GET['type']]) { switch (@$_GET['type']) { case 'county': $location = "" . $counties[$_GET[$_GET['type']]]['name'] . " County"; $message = $location . " is in the " . $counties[$_GET[$_GET['type']]]['region'] . " region."; $msgclass = "result"; break; case 'city': $location = "The city of " . $cities[$_GET[$_GET['type']]]['name'] . ""; $message = $location . " is in the " . $cities[$_GET[$_GET['type']]]['region'] . " region."; $msgclass = "result"; break; } } $db->disconnect(); /**** Functions ****/ /** * Generate HTML \n"; foreach ($result as $key => $item) { $out .= " \n"; } return $out; } /** * Get a list of cities or counties as an array. * Items will be selected from the table named * geo_va_${geo_va_table}. * * @param object $db - DB object * @param string $geo_va_table - table name * @return array */ function get_geo_list(&$db,$geo_va_table) { $out =& $db->getAssoc( 'SELECT t.id, t.name, rg.name AS region FROM geo_va_'.$geo_va_table.' t, geo_deq_regions rg WHERE t.deq_region = rg.id ORDER BY t.name',false,null,DB_FETCHMODE_ASSOC); if (PEAR::isError($out)) { die($out->getMessage()); } return $out; } /**** Template ****/ ?> Virginia DEQ - Region locator

DEQ region locator