-
Notifications
You must be signed in to change notification settings - Fork 2
/
suggest.php
32 lines (27 loc) · 997 Bytes
/
suggest.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
<?
require_once("config.php");
require_once("inc/main.php");
$value = $_REQUEST["value"];
switch($_REQUEST["field"]) {
case "prefix":
case "suffix":
case "title":
$sql = "SELECT ".$_REQUEST["field"]." as value, count(*) total FROM tree_person
WHERE ".$_REQUEST["field"]." LIKE '%".fixTick($value)."%' AND ".actualClause()."
GROUP BY ".$_REQUEST["field"]." ORDER BY total DESC LIMIT 0,10";
break;
case "location":
$sql = "SELECT ".$_REQUEST["field"]." as value, count(*) total FROM tree_event
WHERE ".$_REQUEST["field"]." LIKE '%".fixTick($value)."%' AND ".actualClause()."
GROUP BY ".$_REQUEST["field"]." ORDER BY total DESC LIMIT 0,10";
break;
default:
die("not a valid field type");
}
$data = $db->select($sql);
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\"?><Suggestions>";
foreach($data as $row) echo "<suggestion>".htmlspecialchars($row["value"])."</suggestion>";
echo "</Suggestions>";
//print_pre($data);
?>