我想在从 mysql 数据库中搜索数据时使用 jquery ui 进行自动完成功能....因为 nw 正在使用数组中的数据,但我不知道。我如何从数据库中检查它?这是我的代码。
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: result_array
});
});
</script>
有什么帮助吗?
编辑为:
?php
$q=mysql_query("select rfname from research_details") or die(mysql_error());
$array_data = mysql_fetch_array($q);
foreach($array_data as $data) {
$data1[] = "'".$data."',";
}
$data1 = implode(",",$data1);
$data = substr($data1,0,-1);
?>
$(function() {
var availableTags = [
<?php echo $data; ?>
];
$( "#tags" ).autocomplete({
source:availableTags
});
});
</script>