index.php
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hancie e-Learning Studio</title>
<!-- Script -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<!-- jQuery UI -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs
/jqueryui/1.12.1/jquery-ui.css" />
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js">
</script>
<!-- Bootstrap Css -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/
css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row">
<h2>Search Here</h2>
<input type="text" name="term" id="term" placeholder="
search here...." class="form-control">
</div>
</div>
<script type="text/javascript">
$(function() {
$( "#term" ).autocomplete({
source: 'result.php',
});
});
</script>
</body>
</html>
result.php
<?php
require_once "connection.php";
if (isset($_GET['term'])) {
$query = "SELECT * FROM tea_bill WHERE Name
LIKE '{$_GET['term']}%' LIMIT 25";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
while ($user = mysqli_fetch_array($result)) {
$res[] = $user['Name'];
}
} else {
$res = array();
}
//return json res
echo json_encode($res);
}
?>
connection.php
<?php
$sernamename="localhost";
$username="root";
$password="";
$dbname="tea";
$conn=new mysqli($sernamename, $username, $password, $dbname);
if(!$conn){
die ("Connection fail" .mysqli_error());
}
?>
Output