I want to get the nomeprofi value and send to my php page to load the DB data, but i cant send and it does not enter in the function at all.
This is the script that should get the value and send to autocomplete.php (the script just run once apparently)
$(function() {
var nome = $("#nomeprofi").val();
var nomezinho = "autocomplete.php?nome="+nome;
console.log(nomezinho);
$( "#nomeprofi" ).autocomplete({
source: nomezinho
});
});
This is the input where I type the name of the user
<label>Paciente<input type="text" name="paciente" required></label><br>
I don't know if this will be helpful but... (php page where i get DB data (postgreSQL)
<?php
include("conecta.php"); /* ESTABLISH CONNECTION IN THIS FILE; MAKE SURE THAT IT IS mysqli_* */
$nome = $_GET['nome'];
$sql = "select nome from profissional where nome like '%$nome%'";
//$sql = "select nome from profissional";
$resultado= pg_query($conecta, $sql);
$qtde=pg_num_rows($resultado);
if ($qtde > 0)
{
for ($cont=0; $cont < $qtde; $cont++)
{
$linha=pg_fetch_array($resultado);
$description_arr[]= $linha['nome'];
}
}
echo json_encode($description_arr); /* ECHO ALL THE RESULTS */
?>