我想获取nomeprofi值并发送到我的php页面以加载数据库数据,但是我无法发送,并且它根本没有输入该函数。
这是应该获取值并发送到autocomplete.php的脚本(该脚本显然只运行了一次)
$(function() {
var nome = $("#nomeprofi").val();
var nomezinho = "autocomplete.php?nome="+nome;
console.log(nomezinho);
$( "#nomeprofi" ).autocomplete({
source: nomezinho
});
});
这是我输入用户名的输入
<label>Paciente<input type="text" name="paciente" required></label><br>
我不知道这是否有帮助,但是...(我获取数据库数据的PHP页面(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 */
?>