Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/03/2013, 07:43
tkngrafik
 
Fecha de Ingreso: septiembre-2012
Mensajes: 15
Antigüedad: 11 años, 7 meses
Puntos: 0
Pregunta Búsqueda con filtros Php y Mysql

Hola a tod@s necesito de su ayuda. He realizado un buscador pero solo con <select><option></option></select> pero no he podido lograr que haga filtros en la bùsqueda.........Les pongo el còdigo para si alguien sabe como se hace pueda ayudarme:

Formulario

Código HTML:
Ver original
  1. <form action="propiedades.php" method="post">
  2.    <option>Cualquiera</option>
  3.    <?php while($rowMun = $resMun->fetch_array()){ ?>
  4.    <option value="<?php echo $rowMun['municipio'] ?>">
  5.    <?php echo $rowMun['municipio'] ?>
  6.    </option>
  7.    <?php } ?>
  8.    <option>Cualquiera</option>
  9.    <?php while($rowBar = $resBar->fetch_array()){ ?>
  10.    <option value="<?php echo $rowBar['barrio'] ?>">
  11.    <?php echo $rowBar['barrio'] ?>
  12.    </option>
  13.    <?php } ?>
  14.    <option>Cualquiera</option>
  15.    <?php while($rowTip = $resTip->fetch_array()){ ?>
  16.    <option value="<?php echo $rowTip['tipo'] ?>">
  17.    <?php echo $rowTip['tipo'] ?>
  18.    </option>
  19.    <?php } ?>
  20.    <option>Cualquiera</option>
  21.    <?php while($rowAlc = $resAlc->fetch_array()){ ?>
  22.    <option value="<?php echo $rowTip['alcobas'] ?>">
  23.    <?php echo $rowAlc['alcobas'] ?>
  24.    </option>
  25.    <?php } ?>
  26. <input type="submit" value="realizar b&uacute;squeda">
  27. </form>

Consulta

Código PHP:
Ver original
  1. $municipio            = $_POST['municipio'];
  2. $barrio                 = $_POST['barrio'];
  3. $tipo                    = $_POST['tipo'];
  4. $alcobas              = $_POST['alcobas'];
  5.     //Consulta
  6. $consulta             = ("SELECT idPropiedades, cliente, municipio, barrio, tipo, precio, imagenBig, imagenThu, alt, mapa, alcobas, banos, medidas, resena, detalles
  7.     FROM propiedades
  8.     WHERE municipio       LIKE '%$municipio%'
  9.     AND barrio            LIKE '%$barrio%'
  10.     AND tipo              LIKE '%$tipo%'
  11.     AND alcobas           LIKE '%$alcobas%'");
  12.     $resultado            = $conn->query($consulta);

Código PHP:
Ver original
  1. <section>
  2.         <?php
  3.         $idDatos       = $_GET['idDatos'];
  4.         $queryDet      = "SELECT idPropiedades, cliente, municipio, barrio, tipo, precio, imagenBig, imagenThu, alt, mapa, alcobas, banos, cocina, comedor, patio, agua, energia, gas, telefono, piso, niveles, medidas, resena, detalles FROM propiedades WHERE idPropiedades = ".$idDatos."";
  5.         $resDet        = $conn->query($queryDet);
  6.         while ($rowDet = $resDet->fetch_array()) {?>
  7.         <article>
  8.             <h1><?php echo $rowDet['municipio'] ?> | <?php echo $rowDet['barrio'] ?></h1>
  9.             <h3">$<?php echo number_format($rowDet['precio'],3);?></h3>
  10.             <figure><img src="img/propiedades/<?php echo $rowDet['imagenBig']; ?>" alt="<?php echo $rowDet['alt'] ?>"></figure>
  11.             <div class="panel descripcion">
  12.             <p>"<?php echo $rowDet['resena'] ?>"</p>
  13.             <h3>Datos Importantes</h3>
  14.                          <table class="TextoGeneral tabla">
  15.                       <thead>
  16.                         <tr>                             
  17.                           <th>Alcobas</th>
  18.                           <th>Ba&ntilde;os</th>
  19.                           <th>Cocina</th>
  20.                           <th>Comedor</th>                           
  21.                           <th>Patio</th>
  22.                           <th>Niveles</th>
  23.                         </tr>
  24.                       </thead>
  25.                       <tbody>
  26.                         <tr>
  27.                           <td><?php echo $rowDet['alcobas'] ?></td>
  28.                           <td><?php echo $rowDet['banos'] ?></td>
  29.                           <td><?php echo $rowDet['cocina'] ?></td>
  30.                           <td><?php echo $rowDet['comedor'] ?></td>
  31.                           <td><?php echo $rowDet['patio'] ?></td>
  32.                           <td><?php echo $rowDet['niveles'] ?></td>
  33.                         </tr>
  34.                       </tbody>
  35.                       <thead>
  36.                         <tr>
  37.                           <th>Tipo de Piso</th>
  38.                           <th>Servicio de Agua</th>
  39.                           <th>Servicio de Energ&iacute;a</th>
  40.                           <th>Servicio de Gas natural</th>
  41.                           <th>L&iacute;nea Telef&oacute;nica</th>
  42.                           <th>Tipo de Inmueble</th>
  43.                         </tr>
  44.                       </thead>
  45.                       <tbody>
  46.                         <tr>
  47.                           <td><?php echo $rowDet['piso'] ?></td>
  48.                           <td><?php echo $rowDet['agua'] ?></td>
  49.                           <td><?php echo $rowDet['energia'] ?></td>
  50.                           <td><?php echo $rowDet['gas'] ?></td>
  51.                           <td><?php echo $rowDet['telefono'] ?></td>
  52.                           <td><?php echo $rowDet['tipo'] ?></td>
  53.                         </tr>
  54.                       </tbody>
  55.                     </table>
  56.                     <?php if ($rowDet['mapa'] != ''){?>
  57.                     <a href="<?php echo $rowDet['mapa'] ?>" target="_blank">Ubicaci&oacute;n</a>       
  58.                     <h3>Perfil de la Propiedad</h3>
  59.                     <p><?php echo $rowDet['detalles'] ?></p>
  60.             </div>             
  61.         </article>
  62. </section>


Al realizar la consulta me da resultados pero no con filtros........Muchas gracias por su ayuda