我做了一些研究并完全按照教程进行了一些细微的修改,但我似乎无法让它发挥作用。没有下拉列表。你能看一下代码并告诉我发生了什么吗?
<div class="ui-widget">
<label for="skills">Skills: </label>
<input id="skills">
</div>
<script>
$(function() {
$( "#skills" ).autocomplete({
width:448,
delimiter: /(,|;)\s*/,
lookup: <?php echo "'autocomplete(#skills)'" ?>
});
});
</script>
<?php
$servername = 'localhost';
$username = 'xx';
$password = 'xx';
$con = mysql_connect($servername,$username,$password);
mysql_select_db('c9', $con);
function autocomplete($inputName){
$searchTerm = $_GET[$inputName];
$query = mysql_query("SELECT * FROM clients WHERE fname LIKE '%".$searchTerm."%' ORDER BY fname ASC");
while ($row = mysql_fetch_array(MYSQL_ASSOC)) {
$data[] = $row['fname'];
}
//return json data
echo json_encode($data);
}
?>