The autocomplete is almost working as it should, except for a problem with words that start with an Uppercase.
for example the word 'Brussels':
I will be able to find it when I start typing in the searchbox 'russels', but 'Bru...' will not be found.
looking for words starting with a lowercase is not a problem, 'brussels' will show up once i start typing 'bru'.
Also words like New York will not show up when i start tying 'York', but will when i type 'ork'.
Search.php file
<?php
$dbServername = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName= "vlucht";
$conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
mysqli_set_charset($conn, 'utf8');
$id = $_GET['q'];
$sql = "SELECT discipline FROM overzicht where discipline like '%".$id."%'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo $row["discipline"]. "\n";
}
} else {
echo "0 results";
}
$conn->close();
?>
index.php file:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery.autocomplete.js"></script>
<script>
jQuery(function(){
$("#search").autocomplete("search.php");
});
</script>
</head>
<body>
Discipline : <input type="text" name="q" id="search" placeholder="Geef je discipline in">
</body>
</html>