B
Boltik
Гость
<?php
header('Content-Type: text/html; charset=windows-1251');
define('IN_PHPBB', true);
define('BB_ROOT', '.././');
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require(BB_ROOT ."common.$phpEx");
// Start session management
$user->session_start();
if (isset($_POST['country']))
{
$html = '<select id="country" onchange="region_select();" name="country" >';
$html .= '<option value="-1">Выберите страну</option>';
$result = $db->query("SELECT * FROM bb_country");
while ($row = $db->sql_fetchrow($result))
{
$html .= '<option class="" value="'.$row['country_id'].'">'.$row['name'].'</option>';
}
$html .= '</select>';
echo $html;
}
else if (isset($_POST['region']))
{
$country_id = (int) $_POST['country_id'];
$html = '<select id="region" onchange="city_select();" name="region" >';
$html .= '<option value="-1">Выберите регион</option>';
$result = $db->query("SELECT * FROM bb_region WHERE country_id = $country_id");
while ($row = $db->sql_fetchrow($result))
{
$html .= '<option class="" value="'.$row['region_id'].'">'.$row['name'].'</option>';
}
$html .= '</select>';
echo $html;
}
else if (isset($_POST['region_id']))
{
$region_id = (int) $_POST['region_id'];
$html = '<select id="city" name="city" >';
$html .= '<option value="-1">Выберите город</option>';
$result = $db->query("SELECT * FROM bb_city WHERE region_id = ".$region_id);
while ($row = $db->sql_fetchrow($result))
{
$html .= '<option class="" value="'.$row['city_id'].'">'.$row['name'].'</option>';
}
$html .= '</select>';
echo $html;
}
else
{
die(basename(__FILE__));
}
?>