
Pido por favor ayuda...
El form de busqueda:
Código:
El Buscador:<form name="form1" method="post" action="buq2.php"> <label>Buscar: <input type="text" name="txtBusqueda" id="txtBusqueda"> Ciudad: <select name="selCiudad" id="selCiudad"> <option value="-1" selected>Todas</option> <?php $tablaciudades = mysql_query("SELECT * FROM ciudades ORDER BY nombre DESC"); // Seleccionamos las ciudades de la tabla ciudades while ($registrociudad = mysql_fetch_array($tablaciudades)) { // Vamos a repetir una Option (opcion), de la Lista Desplegable, por cada ciudad en la tabla ?> <option value="<?php echo $registrociudad['id']; ?>"><?php echo $registrociudad['nombre']; ?></option> <?php } // termina la zona de repeticion mysql_free_result($tablaciudades); // se libera la memoria usada por la tabla ?> </select> Ambientes: <select name="selAmbientes" id="selAmbientes"> <option value="-1" selected>Todos</option> <?php //seleccion de ambientes for($i=1;$i<=10;$i++) { ?> <option value="<?php echo $i;?>"><?php echo $i; ?></option> <?php } ?> </select> </select> Precio Venta: <select name="precio"> <option value="">Mostrar Todos</option> <option value="100000-200000">$100000 a $200000</option> <option value="200000-300000">$200000 a $300000</option> </select> </label> <input type="submit" name="cmdBuscar" id="cmdBuscar" value="IR"> </form>
Código PHP:
<?php //Esto es lo que devuelve segun los datos de la tabla de arriba
$sql = "SELECT prueba.*, ciudades.* FROM prueba, ciudades WHERE prueba.idciudad = ciudades.id ";
if (isset($_POST['txtBusqueda'])) {
$sql .= " AND prueba.titulo LIKE '%" . $_POST['txtBusqueda'] . "%' ";
if (intval($_POST['selCiudad']) > 0) {
$sql .= " AND prueba.idciudad = '" . intval($_POST['selCiudad']) . "'";
}
if (intval($_POST['selAmbientes']) > 0) {
$sql .= " AND Habitaciones = '" . intval($_POST['selAmbientes']) . "'";
}
if (intval($_POST['precio']) > 0) {
$precio=$_POST['precio'];
$ed=explode("-",$precio);
$precio1=$ed[0];
$precio2=$ed[1];
$sql .= " AND SELECT precioVenta from prueba where precioVenta between $precio1 and $precio2 = '" . intval($_POST['precio']) . "'";
}
}
$sql .= " ORDER BY ciudades.nombre ASC";
$tabla = mysql_query($sql);
while ($registro = mysql_fetch_array($tabla)) {
?>
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Archivos de programa\EasyPHP5.3.0\www\buq2.php on line 86
Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in C:\Archivos de programa\EasyPHP5.3.0\www\buq2.php on line 99
Que es:
Linea 86 while ($registro = mysql_fetch_array($tabla) ESTO ESTA EN EL BUSCADOR
Linea 99 mysql_free_result($tabla); LUEGO DE QUE MUESTRE EL RESULTADO
Gente, lo intente todo...alguien que la tenga clara y me pueda ayudar??
Gracias!!!!!!!!!!!!!!!