<?
include_once 'sys/inc/start.php';
include_once 'sys/inc/compress.php';
include_once 'sys/inc/sess.php';
include_once 'sys/inc/home.php';
include_once 'sys/inc/settings.php';
include_once 'sys/inc/db_connect.php';
include_once 'sys/inc/ipua.php';
include_once 'sys/inc/fnc.php';
include_once 'sys/inc/user.php';

$set['title'] = 'Выбор страны';
include_once 'sys/inc/thead.php';
title();
aut();
if (isset($_GET['go'])){
echo "Быстрый поиск города:<br/>";
echo'<hr>';
$city2=mysql_fetch_array(mysql_query("SELECT * FROM `city` WHERE `name`='$_POST[city]' LIMIT 1"));
$mycity=NULL;
if (isset($_SESSION['mycity']))$mycity=esc(stripcslashes(htmlspecialchars($_SESSION['mycity'])));
if (isset($city2['city_id']))$mycity=esc(stripcslashes(htmlspecialchars($city2['city_id'])));
$_SESSION['mycity']=$mycity;
$mycity=ereg_replace("( ){1,}","",$mycity);
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `city` WHERE `city_id` like '%".mysql_escape_string($mycity)."%'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>\n";
if ($k_post==0)
{
echo "   <tr>\n";
echo "  <td class='p_t'>\n";
echo "Нет результатов\n";
echo "  </td>\n";
echo "   </tr>\n";
}

$q=mysql_query("SELECT * FROM `city` WHERE `city_id` like '%".mysql_escape_string($mycity)."%' ORDER BY `name`  LIMIT $start, $set[p_str]");
while ($count = mysql_fetch_array($q))
{
$country=mysql_fetch_array(mysql_query("SELECT * FROM `country` WHERE `country_id` = '$count[country_id]'"));
$region=mysql_fetch_array(mysql_query("SELECT * FROM `region` WHERE `region_id` = '$count[region_id]'"));
echo "  <td class='p_t'>\n";
echo "<a href='/mysiti.php?id=$count[region_id]&p=city&amp;st=$count[city_id]&amp;set'>$count[name]</a>($country[name],$region[name])\n";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
}

echo "</table>\n";


if ($k_page>1)str("?id=$id_siti&",$k_page,$page); // Вывод страниц
}else{
$city2=mysql_fetch_array(mysql_query("SELECT * FROM `city` WHERE `name`='$_POST[city]' LIMIT 1"));
echo "<form method=\"post\" action=\"?go\">";
echo "Быстрый поиск города:<br/>";
echo "<input type=\"text\" name=\"city\" maxlength=\"40\"/> </br>\r";
echo "<input type=\"submit\" value=\"Найти\" />";
echo "</form>";
echo'<hr>';
echo "шаг№1)Выбрать свою страну\n";
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `country`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>\n";
if ($k_post==0)
{
echo "   <tr>\n";
echo "  <td class='p_t'>\n";
echo "Нет результатов\n";
echo "  </td>\n";
echo "   </tr>\n";
}

$q=mysql_query("SELECT * FROM `country`  LIMIT $start, $set[p_str]");
while ($count = mysql_fetch_array($q))
{
echo "  <td class='p_t'>\n";
echo "<a href='/region.php?id=$count[country_id]'>$count[name]\n";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
}

echo "</table>\n";


if ($k_page>1)str("?",$k_page,$page); // Вывод страниц
}
echo "<a href='/anketa.php'>В анкету</br>\n";
echo "<a href='/umenu.php'>Кабинет\n";



include_once 'sys/inc/tfoot.php';
?>
