【发布时间】:2013-08-15 11:47:02
【问题描述】:
请帮帮我... 我是新手!请告诉我该怎么做。
已处理的.php
<?php
include_once('../../dbConnect.inc.php');
$sql="SELECT name FROM artist";
$artist = select($sql);
disconnect();
$output_items = array();
while($row = mysql_fetch_array($artist))
{
$results[] = array('label' => $row['name']);
}
echo json_encode($results);
?>
index.php
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#artist").autocomplete(
{
source: 'processed.php',
});
});
</script>
我有这个问题:http://jsbin.com/alaci5
【问题讨论】:
-
你可以在这里看到一些远程加载的例子,jqueryui.com/autocomplete/#remote
-
@Hisamu 我搜索了互联网,但找不到任何有用的东西!比如推荐你的网站,没有php文件
-
因为您的 sql 语句正在寻找所有内容。你应该在你的 sql 语句中有这样的东西
LIKE '%".mysql_real_escape_string($_GET['search-term'])."%'"
标签: php jquery mysql json jquery-ui