-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
32 lines (22 loc) · 739 Bytes
/
search.php
File metadata and controls
32 lines (22 loc) · 739 Bytes
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
<?php
require_once 'db_config.php';
if(!array_key_exists('search', $_POST)) { die("no key"); }
$search = $_POST['search'];
$sql=
"SELECT topics.tpc_id , topics.tpc_title
FROM `topics` LEFT JOIN (`topics_has_label` JOIN `label` ) on (topics.tpc_id = topics_has_label.tpc_id and topics_has_label.lbl_id = label.lbl_id )
WHERE topics.tpc_title REGEXP '".$search."' OR label.lbl_name REGEXP '" .$search. "' LIMIT 0, 10";
$result=$mysqli->query($sql);
if(!$result)
{
die($mysqli->error);
}
$arr = array();
$i=0;
while($query = $result->fetch_array())
{
$res = array('tpc_id'=>$query['tpc_id'],'tpc_title' => $query['tpc_title']);
$arr[] = array('id' => $i, 'res' => $res);
$i++;
}
echo json_encode($arr);