I have problem with jquery autocomplete with database its not working.
My code
test5.php:
<?php
$wynik = mysql_query("SELECT * FROM nabk_t_item_tags")
or die('Błąd zapytania');
if(mysql_num_rows($wynik) > 0) { while($r = mysql_fetch_assoc($wynik)) {
$input = $r['tags'] ;
$fields = explode(',', $input);
foreach($fields as $field) {
echo ''.$field.'<br>'; }}}
?>
<script type="text/javascript">
$(function() {
var availableTags = <?php include('test5.php'); ?>;
$("#tags").autocomplete({
source: availableTags,
autoFocus:true
});
});
</script>
try this
<?php
$wynik = mysql_query("SELECT * FROM nabk_t_item_tags")
or die('Błąd zapytania');
if(mysql_num_rows($wynik) > 0) { while($r = mysql_fetch_assoc($wynik)) {
$input = $r['tags'] ;
$fields = explode(',', $input);
foreach($fields as $field) {
echo '"'.$field.'",'; }}}
?>
<script type="text/javascript">
$(function() {
var availableTags = [<?php include('test5.php'); ?>];
$("#tags").autocomplete({
source: availableTags,
autoFocus:true
});
});
</script>