<?php

include('configi.php');

$q2 = $_REQUEST['term'];
$row = [];

$q = trim(strip_tags($_REQUEST['term']));//retrieve the search term that autocomplete sends

//$sql_res=mysql_query("select * from " . $_COOKIE['phxcrmclient_id'] . "_orders_view where st_id like '%$q%' order by st_id LIMIT 10");

$sql="select * from ".$_COOKIE['phxcrmclient_id']."_jobs_view where st_id like '%$q%' or comp_name like '%$q%' order by st_id LIMIT 10";

//echo $sql;

$result=mysqli_query($conn, $sql);

 while($row = mysqli_fetch_assoc($result))
{
$st_id=$row['st_id'];
$comp_name=$row['comp_name'];

$rep = "<span style='font-weight: bold; text-transform: uppercase;'>".$q2."</span>";
//$prod_title = substr($prod_title, 0, 80);  
//$prod_title = htmlentities(stripslashes($prod_title));
//$prod_title = str_ireplace($q, $rep, $prod_title);
$display_text = "JOB ID: " . $row['st_id'] . " Customer: " . $comp_name;

		$row['value']=$display_text;
		$row['id']=(int)$row['st_id'];
		$row_set[] = $row;//build an array

}

echo json_encode($row_set);//format the array into json data


?>