Whenever I input letter 'a' it suggesting all the name with letter 'a' in the name_table. I want to to make it suggest only the name that start with letter 'a'. How to fix this?.
index.php
<html><script type="text/javascript">
$(function() {
var availableTags = <?php include('autocomplete.php'); ?>;
$("#first_name").autocomplete({
source: availableTags,
autoFocus:true
});
});
</script>
<form>
<label class="w3-label w3-text-green">Name</label>
<input class="w3-input w3-border" style="height: 30px" type="text" id="first_name" name = "name" required>
</form>
</html>
autocomplete.php
<?php
require('connection.php');
$sql = "select name from employee";
$result = mysqli_query($conn, $sql) or die("Error " .
mysqli_error($connection));
$dname_list = array();
while($row = mysqli_fetch_array($result))
{
$fullname = $row['name'];
$dname_list[] = $fullname;
}
echo json_encode($dname_list);
?>