Check out this code snippet for some guidance.
HTML:
<input type="text" id="searchPro" />
All dynamically generated results will be displayed inside the div
<div id="searchLog"></div>
JQuery:
$("#searchPro").autocomplete({
source: function(request,response) {
$.ajax({
url: "php.func.php",
type: "POST",
data: { term: request.term },
success: function (searchData) {
$('#searchLog').html(searchData);
}
})
}
});
PHP: php.func.php
$find = "SELECT *
FROM tbl_products
WHERE (`product_name` LIKE '%".$_REQUEST['term']."%')";
$resset = $conn->query($find);
while ($res = mysqli_fetch_object($resset)) {
$findRes[] = $res;
}
if (!empty($findRes)) {
foreach ($findRes as $ResultSet) {
echo "<tr><td>".$ResultSet->product_name."</td>";
}
}else{
echo "<p>No Result Found for keyword <b>".$_REQUEST['term']."</b>..<p><hr/>";
}
You can find the JQuery Autocomplete link here: [JQuery Autocomplete][1]
This serves as a basic reference code that I have utilized in one of my projects. Feel free to customize it according to your requirements. Hopefully, it proves helpful to you.
For more https://jqueryui.com/autocomplete/