My php code looks like that
if (isset($_REQUEST['term']))
{
$term = trim(strip_tags($_REQUEST['term']));//retrieve the search term that autocomplete sends
$result = $db->query("SELECT company as value,id FROM main WHERE company LIKE '$term'") or die(mysqli_error());;
$results = array();
while ($row = $result->fetch_row()) $results[] = array( 'id' => $row[0] , 'label' => $row[1], 'value' => $row[1] );
echo json_encode($results);
}
Js code below
$("#auto").autocomplete({
source: "index.php",
minLength: 2,//search after two characters
select: function(event,ui){
}
});
And HTML markup
<input id="auto" name="company"/>
What’s wrong with the code? It doesn’t generate autocomplete option.. No error in php log file. How to fix that problem?
assuming json is ok then you are not doing anything with data you get back