Using jquery-ui to perform searches in a head, with suggestions results

0

I have built a search engine that is issuing suggestions as we enter text in your box, is inserted in a header with styles in Bootstrap, to create it, I have used php, MySQL, Ajax, JQuery and JQuery-UI (with its js and css), the search engine consists of a text box and a SEARCH button. When I do a search by clicking on the SEARCH button, it works perfectly, redirecting all the results to a page, but the problem is presented with the suggestions ... it works perfect, but when showing the results ... the first two are hidden under the styles of the Bootstrap header and of course my idea is that they are above this header to be able to see them. Any suggestions?

Form code:

<div class="searchbox">
    <form action="<?php echo RUTA; ?>Buscador/index.php" method="POST">
        <div class="input-group input-group-sm">
            <input type="text" class="form-control" name="buscar" id="buscar" placeholder="Ingrese texto ...">
                <span class="input-group-btn">
                    <input type="submit" class="btn btn-default" value="Buscar"/><i class="fa fa-search"></i>
                    </span>
        </div>
    </form>
</div>

Ajax.php Code:

    <?php 

    $conexion = conexion($bd_config);
    if (!$conexion) {
        $error = "No hay conexion con la base de datos";
        header('Location: error.php');
    }

class Ajax {

    public $buscador;

    public function Buscar($a) {
        $this->buscador = $db->filter_var($a, FILTER_SANITIZE_STRING);
        $sql = $db->query("SELECT SQL_CALC_FOUND_ROWS * FROM alquileres WHERE estado = 1 
        AND nombre LIKE '%$this->buscador%' OR claves LIKE '%$this->buscador%';");

        while ($array = $db->recorrer($sql)) {
            $resultado[] = $array['nombre'];
        }

        return $resultado;
    }
}

$busqueda = new Ajax();
echo json_encode($busqueda->Buscar($_GET['term']));

?>

Code of the Index.php:

    <?php 

$conexion = conexion($bd_config);
if (!$conexion) {
    $error = "No hay conexion con la base de datos";
    header('Location: error.php');
}

if (isset($_POST['buscar']) ) {
    $filtro = filter_var($_POST['buscar'], FILTER_SANITIZE_STRING);
    $propiedades = obtener_propiedades_nombre($conexion, $filtro);

    $total_propiedades = $conexion->query('SELECT FOUND_ROWS() as total_propiedades');
    $total_propiedades = $total_propiedades->fetch()['total_propiedades'];

    if ($total_propiedades > 0) {
        $mensaje_prop = "Se han encontrado " . $total_propiedades . " de resultados en propiedades.";
    } else $mensaje_prop = "No se han encontrado propiedades con el texto ingresado.";

    $servicios = obtener_servicios_nombre($conexion, $filtro);

    $total_servicios = $conexion->query('SELECT FOUND_ROWS() as total_servicios');
    $total_servicios = $total_servicios->fetch()['total_servicios'];

    if ($total_servicios > 0) {
        $mensaje_serv = "Se han encontrado " . $total_servicios . " de resultados en servicios.";
    } else $mensaje_serv = "No se han encontrado servicios con el texto ingresado.";

} else {
    echo '';
}

require 'index.view.php';

?>
    
asked by Ricardo Pastuszek 07.08.2017 в 00:09
source

0 answers