RussianPro
Эксперт
Дата регистрации:
14.07.2011 01:32:38
Сообщений: 114
Сама Функция:
<?php
function advancedSearch($id, $deal, $location, $loca, $move, $square, $value, $realty, $currensy) {
$mysqli = connectDB();
if ($id !== '') $result_set = $mysqli->query("SELECT * FROM projects WHERE `id` = '$id'"
else {
if (($location == 'on') && (($square !== '') || ($value !== ''))) {
$result_set = $mysqli->query("SELECT * FROM projects WHERE (`deal` LIKE '$deal' AND ((`realty` = '$realty' OR `realty` = '$realty[0]' OR `realty` = '$realty[1]' OR `realty` = '$realty[2]' OR `realty` = '$realty[3]' OR `realty` = '$realty[4]' OR `realty` = '$realty[5]' OR `realty` = '$realty[6]' OR `realty` = '$realty[7]') AND ((`location` = '$loca[0]' OR `location` = '$loca[1]' OR `location` = '$loca[2]' OR `location` = '$loca[3]' OR `location` = '$loca[4]' OR `location` = '$loca[5]' OR `location` = '$loca[6]' OR `location` = '$loca[7]' OR `location` = '$loca[8]' OR `location` = '$loca[9]') AND `move` = '$move') AND ((`vfrom` >= '$value' OR `sfrom` >= '$square') AND `currensy` = '$currensy')))"
$a = true;
}
closeDB($mysqli);
return resultToArray($result_set);
}
?>
И ещё одна функция которая возвращает массив с выбранными данными.
<?php
function resultToArray($result_set) {
$results = array();
while (($row = $result_set->fetch_assoc()) != false) {
$results[] = $row;
}
return $results;
}
?>