setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { echo "ERROR : ".$e->getMessage(); } $term=$_GET["term"]; $stmt = $DBcon->prepare("SELECT * FROM staff_table where names like '%".$term."%' order by names"); $stmt->execute(); $json=array(); while($row=$stmt->FETCH(PDO::FETCH_ASSOC)) { $json[]=array( 'value'=> $row["staff_id_no"], 'label'=>$row["names"]." - ".$row["sections"] ); } echo json_encode($json); ?>