Intento hacer un buscador de pisos, mandando datos desde un formulario a un archivo php que debería recoger los criterios del formulario (habitaciones, ascensor, etc) y pedir a la base de datos que muestre que pisos reunen esas condiciones. El código del formulario es:
Código HTML:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Documento sin título</title> </head> <body> <form id="formulario" name="formulario" method="GET" action="busqueda3.php"> <label>habitaciones <select name="habi" size="1" id="habi"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </label><label></label> <label>Ascensor <select name="ascen" size="1" id="ascen"> <option selected="selected">si</option> <option>no</option> </select> </label> <label>Enviar <input type="submit" name="Submit" value="Enviar" /> </label> </form> </body> </html>
Y este es el código del archivo busqueda3.php:
Código PHP:
<?php require_once('Connections/connebd.php'); ?>
<?php
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
$habi_Recordset1 = "habi";
if (isset(#formFieldName#)) {
$habi_Recordset1 = (get_magic_quotes_gpc()) ? #formFieldName# : addslashes(#formFieldName#);
}
$ascen_Recordset1 = "ascen";
if (isset(#formFieldName#)) {
$ascen_Recordset1 = (get_magic_quotes_gpc()) ? #formFieldName# : addslashes(#formFieldName#);
}
mysql_select_db($database_connebd, $connebd);
$query_Recordset1 = sprintf("SELECT * FROM ventapiso WHERE '%s . %s'", $ascen_Recordset1,$habi_Recordset1);
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $connebd) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
<style type="text/css">
<!--
.Estilo1 {font-family: Geneva, Arial, Helvetica, sans-serif}
-->
</style>
</head>
<body>
<table border="1">
<tr>
<td>id</td>
<td>expediente</td>
<td>operacion</td>
<td>zona</td>
<td>orientacion</td>
<td>metros</td>
<td>altura</td>
<td>ascensor</td>
<td>habitaciones</td>
<td>armarios</td>
<td>baños / aseos</td>
<td>calefaccion</td>
<td>terraza</td>
<td>balcones</td>
<td>comunidad</td>
<td>garaje</td>
<td>amueblado</td>
<td>reformado</td>
<td>trastero</td>
<td>plano</td>
<td>foto</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['id']; ?></td>
<td><?php echo $row_Recordset1['expediente']; ?></td>
<td><?php echo $row_Recordset1['operacion']; ?></td>
<td><?php echo $row_Recordset1['zona']; ?></td>
<td><span class="Estilo1"><?php echo $row_Recordset1['orientacion']; ?></span></td>
<td><?php echo $row_Recordset1['metros']; ?></td>
<td><?php echo $row_Recordset1['altura']; ?></td>
<td><?php echo $row_Recordset1['ascensor']; ?></td>
<td><?php echo $row_Recordset1['habitaciones']; ?></td>
<td><?php echo $row_Recordset1['armarios']; ?></td>
<td><?php echo $row_Recordset1['baños / aseos']; ?></td>
<td><?php echo $row_Recordset1['calefaccion']; ?></td>
<td><?php echo $row_Recordset1['terraza']; ?></td>
<td><?php echo $row_Recordset1['balcones']; ?></td>
<td><?php echo $row_Recordset1['comunidad']; ?></td>
<td><?php echo $row_Recordset1['garaje']; ?></td>
<td><?php echo $row_Recordset1['amueblado']; ?></td>
<td><?php echo $row_Recordset1['reformado']; ?></td>
<td><?php echo $row_Recordset1['trastero']; ?></td>
<td><?php echo $row_Recordset1['plano']; ?></td>
<td><?php echo $row_Recordset1['foto']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>