I'm trying to use jquery to do an auto complete in my search field. The connection to the bank is correct and I use the following code to save the files:
<?php
INCLUDE "conexao.php";
$sql = "SELECT * FROM consulta";
$result = mysqli_query($conexao, $sql);
$potential = mysql_fetch_array($result);
echo json_encode($potential);
?>
Using this javascript code, auto complete works:
<script>
$(function() {
var availableTags = [
"Felipe Arcaro",
"Amanda Bertollini",
"Rafael Manaus",
"Gleidson",
"Guilherme Sato",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
But using this, no:
<script>
$(document).ready(function(){
var availableTags = <?php print(json_encode($potential)); ?>;
console.log(myArray);
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>