forked from opencaching/opencaching-pl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajaxGetRegionsByCountryCode.php
36 lines (31 loc) · 1.45 KB
/
ajaxGetRegionsByCountryCode.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
$rootpath = __DIR__ . DIRECTORY_SEPARATOR;
require_once $rootpath . 'lib/common.inc.php';
$db = new dataBase;
$countryCode = addslashes($_REQUEST['countryCode']);
$selectedRegion = $_REQUEST['selectedRegion'];
$query = "SELECT `code`, `name` FROM `nuts_codes` WHERE `code` LIKE '" . $countryCode . "__' ORDER BY `name` COLLATE utf8_polish_ci ASC";
$db->simpleQuery($query);
$regons = $db->dbResultFetchAll();
if (count($regons) == 0) {
if (isset($_REQUEST['searchForm']) && $_REQUEST['searchForm'] == 1) {
$regionoptions = '<option value="">' . tr('search01') . '</option>';
} else {
$regionoptions = '<option value="-1">-</option>';
}
} else {
if (isset($_REQUEST['searchForm']) && $_REQUEST['searchForm'] == 1) {
$regionoptions = '<option value="">' . tr('search01') . '</option>';
} else {
$regionoptions = '<option value="0">' . tr('select_regions') . '</option>';
}
foreach ($regons as $record) {
if ($record['code'] == $selectedRegion)
$regionoptions .= '<option value="' . htmlspecialchars($record['code'], ENT_COMPAT, 'UTF-8') . '" selected="selected" >' . htmlspecialchars($record['name'], ENT_COMPAT, 'UTF-8') . '</option>';
else
$regionoptions .= '<option value="' . htmlspecialchars($record['code'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record['name'], ENT_COMPAT, 'UTF-8') . '</option>';
$regionoptions .= "\n";
}
}
echo $regionoptions;
?>