I am having two problems. Right now my autocomplete is showing all 600 results no matter what I type in it never narrows down to fewer results. I also need it to display only the closest 5 results that match what I am typing. Any ideas on how to improve this.
PHP
<?php
include('inc/connections.php');
$sql = "select top 5 a.item_desc_1, b.item_no from bmprdstr_sql b, imitmidx_sql a
where a.item_no=b.comp_item_no and b.user_def_fld = 'x'
AND b.item_no like '%{$_POST['auto_me']}%'
";
$query = odbc_exec($conn, $sql);
$json = array();
while ($row = odbc_fetch_array($query)) {
$json[] = $row['item_no'];
}
echo json_encode($json);
JQUERY HTML
<html>
<head>
<title>
test
</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(document).ready(function(){
$(function() {
$("#auto_me").autocomplete({
source: 'auto_complete.php',
autoFocus:true
});
});
});
</script>
</head>
<body>
<form id="auto">
<input type="text" id="auto_me" name="auto_me"/>
</form>
</body>
</html>