The autocomplete of this code should show me the articles I have in a database of MySql
, but every time something is written inside the text box it shows me no search result
. I already verified that the connection data are correct, and despite different querys
I still mark the same.
<?php
$mysqli = new mysqli("localhost", "root", "root", "inventarios");
if($mysqli === false) {
die("ERROR: No se estableció la conexión. " . mysqli_connect_error());
}
if(!isset ($_REQUEST['buscar']))
exit;
$sql = "select 'Nom_Art' from 'articulos' WHERE 'Nom_Art' LIKE '%$buscar%'";
$result = $conex->listaObjetos($sql);
if(count($result) < 0)
exit;
$data = array();
foreach($result as $r) {
$data[] = array(
'label' => $r->buscar,
'value' => $r->buscar
);
}
echo json_encode($data);
flush();
?>
And that code is used here.
<!DOCTYPE html>
<html lang="es">
<head>
<title>prueba</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<link href="http://cdnjs.cloudflare.com/ajax/libs/jQuery-Validation-Engine/2.6.4/validationEngine.jquery.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jQuery-Validation-Engine/2.6.4/jquery.validationEngine.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jQuery-Validation-Engine/2.6.4/languages/jquery.validationEngine-es.js"></script>
<style>
.top-buffer {
margin-top:20px;
}
</style>
</head>
<script type="text/javascript">
jQuery(document).ready(function(){
$("#buscar").autocomplete({source:"llenado.php", minLength:'4'});
});
</script>
<body>
<form>
<p><label for="buscar">Priueba</label>
<input type="text" name="buscar" id="buscar" method="get" size="35" minlength="4"/>
</p>
</form>