core/api/modules/find_clients/ajax.php

37 lines
1.1 KiB
PHP
Executable File

<?php
function clear_json ($text) { // ФУНКЦИЯ очистки кода для xml
$old1 = array('\"', '\/');#Ищем вредное ">",, "<"
$new1 = array('"', '/');#Меняем на полезное"&gt;", , "&lt;"
$text = str_replace($old1, $new1, $text);#Собсно сама замена =)
return $text;
}
switch(@$_POST['act']) {
case 'get_json':
// print_r($_POST);
$sql="SELECT `id`, `fio`, `login`, `ava`, `reyt`, `stazh`, `o_sebe` FROM `users` WHERE ";
if ($_POST['gorod'])$sql.= " `gorod` LIKE '%" . $_POST['gorod'] . "%' AND";
if ($_POST['stazh'])$sql.= " `stazh` >= " . $_POST['stazh'] . " AND";
if ($_POST['vozrast'])$sql.= " `vozrast` >= " . $_POST['vozrast'] . " AND";
if ($_POST['zhanr'])$sql.= " `zhanr` LIKE '%" . $_POST['zhanr'] . "%' AND";
$sql_end=" `act`=1 ORDER BY `reyt` DESC";
$sql.=$sql_end;
//echo $sql;
$massiv=$db->free_sql($sql);
$massiv[0]['o_sebe']=nl2br($massiv[0]['o_sebe']);
$json=clear_json(json_encode($massiv, JSON_UNESCAPED_UNICODE));
echo $json;
break;
default:
}
?>