I need to display search results using jQuery Autocomplete feature, I have to display results like this site when searching on brand name.
I have categories in table, when searching with brand name results should be display like below
Example: I am searching for Samsung. Results should be show like below
<pre>
Samsung
in Mobiles
in Tablets
</pre>
I have provided table image for understanding easy. If user type brand name that brand name should bring parent categories under list. In this image samsung name had two parent categories one is Mobiles and another is Tablets.
I am using this to get results but only category names displaying.
$term = $_GET["term"];
$json=array();
$st = $db->prepare("select * from category where name like '".$term."%' " );
$st->execute();
while($row = $st->fetch(PDO::FETCH_ASSOC))
{
$json[]=array(
'value'=> $row["name"],
'label'=>$row["name"]
);
}
echo json_encode($json);