Good evening, I'm trying to auto-complete an input via query in mysql database, but I'm having problems. I did all the code following a tutorial and even then it will not, nor will any errors appear to me. When I type, there are no options to complete. Here is the code:
pg index
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Auto Complete</title>
<link rel="stylesheet" href="assets/js/jquery-ui.css" />
<script src="assets/js/jquery-3.3.1.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/jquery-ui.js"></script>
</head>
<body>
<form action="t" method="POST" accept-charset="utf-8">
<label>Cliente:</label>
<input type="text" id="assunto" name="assunto">
</form>
<script type="text/javascript">
$(document).ready(function(){
$("#assunto").autocomplete({
source: 'retornaCliente.php'
});
});
</script>
</body>
</html>
pg returnCustomer
<?php
include 'conexao.php';
$pdo = conectar();
$assunto = filter_input(INPUT_GET, 'term', FILTER_SANITIZE_STRING);
$buscar = $pdo->prepare("SELECT NOME_LOJA FROM lojas WHERE NOME_LOJA LIKE '%".$assunto."%' ORDER BY NOME_LOJA ASC ");
$buscar->execute();
while ($result = $buscar->fetch(PDO::FETCH_ASSOC)) {
$dados[] = $result['NOME_LOJA'];
}
echo json_encode($dados);
$assunto = filter_input(INPUT_GET, 'term', FILTER_SANITIZE_STRING);
//SQL para selecionar os registros
$result_msg_cont = "SELECT assunto FROM mensagens_contatos WHERE assunto LIKE '%".$assunto."%' ORDER BY assunto ASC LIMIT 7";
//Seleciona os registros
$resultado_msg_cont = $conn->prepare($result_msg_cont);
$resultado_msg_cont->execute();
while($row_msg_cont = $resultado_msg_cont->fetch(PDO::FETCH_ASSOC)){
$data[] = $row_msg_cont['assunto'];
}
echo json_encode($data)
?>
The connection to the bank is ok because I tested it separately, if you can, help me thanks.