<?php

include('configi.php');
$phxcrmclient_id = $_COOKIE['phxcrmclient_id'];


$q2 = $_REQUEST['term'];

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

$sql = "select * from ".$phxcrmclient_id."_staff where staff_name like '%$q%' order by staff_name LIMIT 15 ";

//echo $sql;
$i = 0;


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

 while($row = mysqli_fetch_assoc($result))
{
	$staff_name		=	$row['staff_name'];
	$uid			=	$row['uid_staff'];




	//	if ($i == 0){
	//		$row['value']="All ".$q;
	//		$row['0']=(int)$row['uid'];
	//		$row_set[] = $row;//build an array
	//	}

		$display_text = $staff_name;

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


	$i = $i + 1;
	
}

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


?>