1
Good afternoon,
I’m trying to make an autocomplete, I followed some tutorials on the internet and here, but I think I’m sinning in some detail. My input in index.php
<div class="container d-flex justify-content-center" >
<div class="col-lg-6">
<form action="" method="post">
<div class="input-group">
<input type="text" class="form-control" placeholder="Digite aqui o seu problema com palavras chaves" name="titulo" autocomplete="off" autofocus="" required="" id="auto">
<span class="input-group-btn" style="padding-left: 10px">
<button class="btn btn-success" type="submit">Pesquisar</button>
</span>
</div>
</form>
</div>
</div>
Javascript in index.php
<script type="text/javascript">
$(function() {
//autocomplete
$("#auto").autocomplete({
source: "procura.php",
minLength: 1
});
});
</script>
php search.
<?php
include 'conexao.php';
$titulo = $_GET['titulo'];
$return_arr = array();
echo $sql = "SELECT * FROM artigos where titulo = '%". $titulo ."%'";
$busca = oci_parse($conexao, $sql);
oci_execute($busca);
while($dados = oci_fetch_array($busca)) {
$return_arr[] = $dados['TITULO'];
}
/* Toss back results as json encoded array. */
echo json_encode($return_arr);
?>
Something’s not adding up, thank you!
Wow, but I took -1 pq?
– Diskteka Oficial
probably the error is "echo $sql = ..." which is returning to its sql before the json code with the results
– Jader A. Wagner
you can also access the search.php? title=something directly in the browser to test if the return is coming as expected.
– Jader A. Wagner