Hi here i am using the jquery auto-complete plugin. i have some php retrieved database values i want to use those values in the autocomplete plugin. for that i want to get the php values to javascript array. how can i do this?
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
];
$( "#category" ).autocomplete({
source: availableTags
});
});
Php:
<?php
require_once "config.php";
$q = strtolower($_GET["q"]);
if (!$q) return;
$sql = "select distinct(category) from completer";
$rsd = mysql_query($sql);
while($rs = mysql_fetch_array($rsd)) {
$fname = $rs['category'];
echo "$fname"
}
?>
json_encode($your_array);