//проверяем введены ли параметры поиска
if (empty($_POST['sh_speak']) and
empty($_POST['sh_learning']) and
empty($_POST['sh_country']) and
empty($_POST['sh_sex']) and
empty($_POST['select_age'])) {
//!isset($_POST['native_speaker']) and
//!isset($_POST['photo']) and
//!isset($_POST['on_line'])
//параметры поиска не введены, проверяем $_GET['page']
if (!isset($_GET['page'])) {
exit("<div class='text'>You must fill one field</div>");
} else {
//передаем данные из $_SESSION['query'] в $where
$where = $_SESSION['query'];
}
} else {
//параметры поиска введены, формируем переменную $where
$where = ' 1 ';
if (!empty($_POST['sh_speak']))
$where = $where . " AND speak = '{$_POST['sh_speak']}'";
if (!empty($_POST['sh_learning']))
$where = $where . " AND learning = '{$_POST['sh_learning']}'";
if (!empty($_POST['sh_country']))
$where = $where . " AND country = '{$_POST['sh_country']}'";
if (!empty($_POST['sh_sex']))
$where = $where . " AND sex = '{$_POST['sh_sex']}'";
if (!empty($_POST['select_age'])) {
$age = $_POST['select_age'];
$timestamp = time();
$date_time_array = getdate($timestamp);
$month = $date_time_array['mon'];
$day = $date_time_array['mday'];
$year = $date_time_array['year'];
if ($age == 'under_18') {
$timestamp = mktime(0, 0, 0, $month, $day, $year - 18);
$date_lim = strftime('%Y-%m-%d', $timestamp);
$data_where = "birth > '$date_lim'";
}
if ($age == '18-25') {
$timestamp = mktime(0, 0, 0, $month, $day, $year - 18);
$timestamp2 = mktime(0, 0, 0, $month, $day, $year - 25);
$date_lim = strftime('%Y-%m-%d', $timestamp);
$date_lim2 = strftime('%Y-%m-%d', $timestamp2);
$data_where = "birth > '$date_lim2' AND birth < '$date_lim'";
}
if ($age == '26-35') {
$timestamp = mktime(0, 0, 0, $month, $day, $year - 26);
$timestamp2 = mktime(0, 0, 0, $month, $day, $year - 35);
$date_lim = strftime('%Y-%m-%d', $timestamp);
$date_lim2 = strftime('%Y-%m-%d', $timestamp2);
$data_where = "birth > '$date_lim2' AND birth < '$date_lim'";
}
if ($age == '35+') {
$timestamp = mktime(0, 0, 0, $month, $day, $year - 35);
$date_lim = strftime('%Y-%m-%d', $timestamp);
$data_where = "birth < '$date_lim'";
}
$where = $where . " AND $data_where";
}
[PHP]