-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax_dropdownlist.php
40 lines (33 loc) · 1.6 KB
/
ajax_dropdownlist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Content-type: application/json"); // JSON
$noCompression = true;
$flagNoAuth = true;
include("common/auth.php");
$q = urldecode($_GET["q"]);
$table = urldecode($_GET["table"]);
$prefix = urldecode($_GET["prefix"]);
$limit = $_GET['limit']?(integer)$_GET['limit']:20;
$fldTitle = Array("Title"=>"Title","TitleLocal"=>"TitleLocal");
if ($table=="stbl_user") $fldTitle=Array("Title"=>"Name","TitleLocal"=>"NameLocal");//--------- Костыли для нестандартной таблицы с юзерами
if (strlen($q)>1){
$sql = "SELECT `".$prefix."ID` as optValue, `".$prefix.$fldTitle["Title"]."` as optText, `".$prefix.$fldTitle["TitleLocal"]."` as optTextLocal
FROM `".$table."`
WHERE (`".$prefix.$fldTitle["Title"]."` LIKE '%".addslashes($q)."%'
OR `".$prefix.$fldTitle["TitleLocal"]."` LIKE '%".addslashes($q)."%'
OR `".$prefix.$fldTitle["TitleLocal"]."` LIKE '%".addslashes(mb_convert_case($q, MB_CASE_TITLE, "UTF-8"))."%'
OR `".$prefix.$fldTitle["TitleLocal"]."` LIKE '%".addslashes(mb_convert_case($q, MB_CASE_UPPER, "UTF-8"))."%'
)
".(!$_GET['deleted']?"AND `".$prefix."FlagDeleted`<>1":"")."
ORDER BY `".$prefix.$fldTitle["Title"]."`, `".$prefix.$fldTitle["TitleLocal"]."`
LIMIT $limit;";
$rs = $oSQL->do_query($sql);
$strOutput = "";
while ($rw=$oSQL->fetch_array($rs)){
$strOutput.= ($strOutput!="" ? ",\r\n" : "").json_encode($rw);
}
echo "{\"data\":[".$strOutput."]}";
}
//echo $strOutput;
?>