El problema: Las ciudades a mostrar se supone que las saco de una base de datos, la cual esta bien conectada, pero en el listbox no me las muestra.
Código HTML:
<html> <head> <title>Reporte de Propiedades</title> </head> <body> <h1>Búsqueda de Propiedades</h1> <form name="form1" method="post" action="busquedapropiedades2.php"> <label>Buscar: <input type="text" name="txtBusqueda" id="txtBusqueda"> </label> <label>Ciudad: <select name="city" size="1" id="city" value="<?echo $sql;?>"> </select> </label> <input type="submit" name="cmdBuscar" id="cmdBuscar" value="IR"> </form> <table border="1"> <tr> <td>ID Propiedad </td> <td>Tipo</td> <td>Ciudad</td> <td>Metros 2</td> <td>Precio</td> </tr> <?php $conexion = mysql_connect('localhost', 'pablo', 'pablo'); mysql_select_db('propiedades'); $sql = "SELECT p.*, c.* FROM propiedades, ciudades WHERE p.ciudades_idciudades=c.idciudades"; if (isset($_POST['txtBusqueda'])) { $sql .= " AND p.tipo LIKE '%" . $_POST['txtBusqueda'] . "%' "; if (intval($_POST['city']) > 0) { $sql .= " AND c.nombre = '" . intval($_POST['city']) . "'"; } $sql .= " ORDER BY ciudades.nombre ASC"; $tabla = mysql_query($sql); } else { $sql = mysql_query("SELECT p.idpropiedades, p.ciudades_idciudades, p.tipo, p.m2, p.valor, c.nombre FROM propiedades p, ciudades c WHERE p.ciudades_idciudades=c.idciudades ORDER BY p.m2 ASC"); } while ($registro = mysql_fetch_array($sql)) { ?> <tr> <td><?php echo $registro['idpropiedades']; ?></td> <td><?php echo $registro['tipo']; ?></td> <td><?php echo $registro['nombre']; ?></td> <td><?php echo $registro['m2']; ?></td> <td><?php echo $registro['valor']; ?> </td> </tr> <?php } mysql_free_result($tabla); mysql_close($conexion); ?> </table> </body> </html>
Código PHP:
<?php
$conexion = mysql_connect('localhost', 'pablo', 'pablo');
mysql_select_db('propiedades');
$sql = "SELECT p.*, c.* FROM propiedades, ciudades WHERE p.ciudades_idciudades=c.idciudades";
if (isset($_POST['txtBusqueda'])) {
$sql .= " AND p.tipo LIKE '%" . $_POST['txtBusqueda'] . "%' ";
if (intval($_POST['city']) > 0) {
$sql .= " AND c.nombre = '" . intval($_POST['city']) . "'";
}
$sql .= " ORDER BY ciudades.nombre ASC";
$tabla = mysql_query($sql);
} else {
$sql = mysql_query("SELECT p.idpropiedades, p.ciudades_idciudades, p.tipo, p.m2, p.valor, c.nombre
FROM propiedades p, ciudades c
WHERE p.ciudades_idciudades=c.idciudades
ORDER BY p.m2 ASC");
}
while ($registro = mysql_fetch_array($sql)) {
?>
<tr>
<td><?php echo $registro['idpropiedades']; ?></td>
<td><?php echo $registro['tipo']; ?></td>
<td><?php echo $registro['nombre']; ?></td>
<td><?php echo $registro['m2']; ?></td>
<td><?php echo $registro['valor']; ?> </td>
</tr>
<?php
}
mysql_free_result($tabla);
mysql_close($conexion);
?>
SI ven el error me dicen profa....
GRACIAS!!!