Опитайте следния код...
html
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/minified/jquery-ui.min.css" type="text/css" />
<p><label>Country:</label><input type='text' name='country' value='' class='auto'></p>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function()
{
$(".auto").autocomplete({
source: "autocomplete.php",
minLength: 1
});
});
</script>
autocomplete.php
<?php
mysql_connect("localhost", "root", "")or die("cannot connect");
mysql_select_db("test")or die("cannot select DB");
$query = $_GET['term'];
$mysql_query = mysql_query("SELECT * FROM users WHERE name LIKE '%{$query}%'");
while ($row = mysql_fetch_assoc($mysql_query))
{
$array[] = $row['name'];
}
echo json_encode ($array);