38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
|
||
|
|
|
||
|
|
if(isset($_REQUEST['temp_region'])) {
|
||
|
|
$temp_region = $_REQUEST['temp_region'];
|
||
|
|
|
||
|
|
$sql_getRegion = "select rf_regions.* from rf_regions as parent
|
||
|
|
join rf_regions on rf_regions.parent = parent.id
|
||
|
|
where parent.id = " . $temp_region . " ORDER BY id ASC";
|
||
|
|
$rezRegion = mysql_query($sql_getRegion);
|
||
|
|
$region = [];
|
||
|
|
while ($row = mysql_fetch_assoc($rezRegion)) {
|
||
|
|
$region[] = $row;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$sql = "SELECT * from metro where region_rf_id = " . $region[0]['id'];
|
||
|
|
if (isset($region[1])) {
|
||
|
|
$sql .= " or region_rf_id = " . $region[1]['id'];
|
||
|
|
}
|
||
|
|
$rez = mysql_query($sql);
|
||
|
|
$num_rows = mysql_num_rows($rez);
|
||
|
|
|
||
|
|
if ($num_rows > 0) {
|
||
|
|
echo "<optgroup label=''>";
|
||
|
|
$rez = mysql_query($sql);
|
||
|
|
while ($m = mysql_fetch_assoc($rez)) {
|
||
|
|
if (isset($metro[$m['id']])) {
|
||
|
|
$sl = "selected";
|
||
|
|
} else {
|
||
|
|
$sl = "";
|
||
|
|
}
|
||
|
|
echo "<option value='$m[id]' $sl>$m[metro]</option>";
|
||
|
|
}
|
||
|
|
echo "</optgroup>";
|
||
|
|
}
|
||
|
|
}
|