File: /var/www/nclive/backend/spsearchsu.php
<?php
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
/* ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL); */
include 'config.php';
if (isset($_REQUEST['query'])) {
$query = $_REQUEST['query'];
$query = $db->query("SELECT t1.exam_id, t1.exam_name, t2.name FROM sp_exam as t1
LEFT JOIN sp_exam_category as t2 on t2.cat_id=t1.cat_id
WHERE t1.exam_name LIKE '%$query%' ");
$array = array();
while ($row = $query->fetch()) {
$array[] = array (
'label' => $row['exam_name'],
'id' => $row['exam_id'],
'value' => $row['exam_name'] . ' in ' . $row['name'],
);
}
echo json_encode ($array);
}
?>