Foros del Web » Programando para Internet » PHP »

resultado de busqueda.

Estas en el tema de resultado de busqueda. en el foro de PHP en Foros del Web. antes que nada, hola a todos. Soy nuevo, me dicen insa y me estoy metiendo a la programacion php.Me recomendaron este foro para sacarme algunas ...
  #1 (permalink)  
Antiguo 17/03/2005, 08:20
 
Fecha de Ingreso: marzo-2005
Mensajes: 10
Antigüedad: 19 años
Puntos: 0
Pregunta resultado de busqueda.

antes que nada, hola a todos. Soy nuevo, me dicen insa y me estoy metiendo a la programacion php.Me recomendaron este foro para sacarme algunas dudas, por eso acudo ahora a uds.

tengo 2 paginas: 1º que es el buscador y la 2º es donde lista el resultado. A continuacion les paso los codigos.

buscar.php
Código PHP:
<form action="listado.php"$edif"&l="$local"&s="$situa"" method="post" name="buscar" id="buscar">
  <table width="100%"  border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td bgcolor="#990000"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td bgcolor="#CCCCCC"><table width="100%"  border="0" cellspacing="0" cellpadding="1">
          <tr>
            <td align="center" bgcolor="#333333"><span class="Estilo1">Busqueda</span></td>
          </tr>
          <tr>
            <td align="right" bgcolor="#e7e7e7" class="Estilo5">EDIFICACION</td>
          </tr>
          <tr>
            <td align="right">
              <select name="edif" class="Estilo2" id="edif">
                <option value="" selected>Todas</option>
                <?php
do {  
?>
                <option value="<?php echo $row_edif['IdEdificacion']?>"><?php echo $row_edif['dsEdificacion']?></option>
                <?php
} while ($row_edif mysql_fetch_assoc($edif));
  
$rows mysql_num_rows($edif);
  if(
$rows 0) {
      
mysql_data_seek($edif0);
      
$row_edif mysql_fetch_assoc($edif);
  }
?>
              </select>
            </td>
          </tr>
          <tr>
            <td align="right" bgcolor="#e7e7e7" class="Estilo5">LOCALIDAD</td>
          </tr>
          <tr>
            <td align="right"><select name="local" class="Estilo2" id="local">
              <option value="" selected>Todas</option>
              <?php
do {  
?>
              <option value="<?php echo $row_local['IdLocalidad']?>"><?php echo $row_local['dsLocalidad']?></option>
                <?php
} while ($row_local mysql_fetch_assoc($local));
  
$rows mysql_num_rows($local);
  if(
$rows 0) {
      
mysql_data_seek($local0);
      
$row_local mysql_fetch_assoc($local);
  }
?>
            </select></td>
          </tr>
          <tr>
            <td align="right" bgcolor="#e7e7e7" class="Estilo5">SITUACION</td>
          </tr>
          <tr>
            <td align="right"><select name="situa" class="Estilo2" id="situa">
              <option value="" selected>Todas</option>
              <?php
do {  
?>
              <option value="<?php echo $row_situa['IdSituacion']?>"><?php echo $row_situa['dsSituacion']?></option>
                <?php
} while ($row_situa mysql_fetch_assoc($situa));
  
$rows mysql_num_rows($situa);
  if(
$rows 0) {
      
mysql_data_seek($situa0);
      
$row_situa mysql_fetch_assoc($situa);
  }
?>
            </select></td>
          </tr>
          <tr>
            <td bgcolor="#333333"><img src="imagenes/1x2.gif" width="1" height="1"></td>
          </tr>
          <tr>
            <td align="center"><input name="Submit" type="submit" class="Estilo2" value="Buscar">              </td>
          </tr>
          <tr>
            <td><img src="imagenes/1x2.gif" width="1" height="1"></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr></table>
  <?php
  mysql_free_result
($edif);
  
mysql_free_result($local);
  
mysql_free_result($situa);
  
?>
  </form>

listado.php
Código PHP:
<?php require_once('Connections/ecoprop.php'); ?>
<?php
mysql_select_db
($database_ecoprop$ecoprop);
$query_props sprintf("SELECT a.IdPropiedad, a.idEdificacion, a.idLocalidad, a.idSituacion, a.dsFoto1, a.dsCodigo, a.dsDireccion, a.dsEntrecalle, a.dsYcalle, a.dsAmbientes, a.idMoneda, a.dsValor, b.dsEdificacion, c.dsLocalidad, d.dsSituacion, e.dsMoneda FROM propiedades = a, edificacion = b, localidad = c, situacion = d, moneda = e WHERE a.idEdificacion = %s AND a.idEdificacion = b.idEdificacion AND a.idLocalidad = c.idLocalidad AND a.idSituacion = d.idSituacion AND a.idMoneda = e.idMoneda ORDER BY b.dsEdificacion ASC, c.dsLocalidad ASC, d.dsSituacion ASC");
$props mysql_query($query_props$ecoprop) or die(mysql_error());
$row_props mysql_fetch_assoc($props);
$totalRows_props mysql_num_rows($props);
if (!empty(
$edif) AND !empty($local) AND !empty($situa))
{
$sql"SELECT * FROM propiedades WHERE idEdificacion LIKE '%$edif%' AND idLocalidad LIKE '%$local%' AND idSituacion LIKE '%$situa%'";
}
else
{
if(!empty(
$edif)) 
{
$sql="SELEECT * FROM propiedades WHERE idEdificacion LIKE '%$edif%'";
}
else
{
$sql="SELEECT * FROM propiedades WHERE idLocalidad LIKE '%$local%'";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/base.dwt.php" codeOutsideHTMLIsLocked="false" -->
<?php
mysql_select_db
($database_ecoprop$ecoprop);
$query_dato "SELECT dsTTLpagina FROM datos";
$dato mysql_query($query_dato$ecoprop) or die(mysql_error());
$row_dato mysql_fetch_assoc($dato);
$totalRows_dato mysql_num_rows($dato);
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo $row_dato['dsTTLpagina']; ?></title>
<style type="text/css">
<!--
body {
    background-image: url(imagenes/wall.gif);
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
.Estilo1 {font-family: Arial, Helvetica, sans-serif}
.Estilo3 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
}
a:link {
    color: #000000;
    text-decoration: none;
}
a:visited {
    color: #000000;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
    color: #000000;
}
a:active {
    text-decoration: none;
    color: #000000;
}
.Estilo4 {color: #000000}
-->
</style>
<style type="text/css">
<!--
.Estilo5 {
    font-family:Arial, Helvetica, sans-serif;
    font-size: 14px;
}
.Estilo6 {
    font-family:Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-weight: bold
}
.Estilo7 {
    font-family:Arial, Helvetica, sans-serif;
    color: #FF0000;
    font-size: 14px;
    font-weight: bold
}
.Estilo8 {
    font-size: 12px;
    font-family: Arial, Helvetica, sans-serif;
}
-->
</style>
<body>
<p align="center" class="Estilo3 Estilo6">Listado de propiedades</p>
                <?php do { ?>
                <table width="100%" border="0" cellspacing="1" cellpadding="1">
                    <tr>
                      <td width="110" align="center" valign="middle"><img name="img" src="Fotos/<?php echo $row_props['dsFoto1']; ?>" width="110" height="85" alt="" style="background-color: #00CCFF"></td>
                      <td align="left" valign="middle"><table width="100%" border="0" cellspacing="1" cellpadding="5">
                        <tr>
                          <td bgcolor="#FFD9B3"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="40%" class="Estilo6"><strong><?php echo $row_props['dsEdificacion']; ?></strong></td>
                              <td width="35%" align="center" class="Estilo7"><?php echo $row_props['dsSituacion']; ?></td>
                              <td width="25%" align="right"><span class="Estilo3">CODIGO </span><span class="Estilo3 Estilo10">: </span><span class="Estilo8"><?php echo $row_props['dsCodigo']; ?></span></td>
                            </tr>
                          </table></td>
                        </tr>
                        <tr>
                          <td><span class="Estilo5"><?php echo $row_props['dsDireccion']; ?>, entre la calle <?php echo $row_props['dsEntrecalle']; ?> y la calle <?php echo $row_props['dsYcalle']; ?></span></td>
                        </tr>
                        <tr>
                          <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="40%" class="Estilo6"><?php echo $row_props['dsLocalidad']; ?></td>
                              <td width="35%" align="center"><span class="Estilo3">Amb.: </span><span class="Estilo1"><?php echo $row_props['dsAmbientes']; ?></span></td>
                              <td width="25%" align="right" class="Estilo6"><?php echo $row_props['dsMoneda']; ?> <?php echo $row_props['dsValor']; ?></td>
                            </tr>
                          </table></td>
                        </tr>
                      </table></td>
                      </tr>
                                </table>
                <?php } while ($row_props mysql_fetch_assoc($props)); ?>
                <p>&nbsp;</p>
</div>
</body>
</html>
<?php
mysql_free_result
($props$sql);
?>
en la pagina listado.php tengo que meterle como si fuera un triple filtro para que muestre solo lo requerido en buscar.php.

lei algo de los $query pero no se donde ponerlo. Yo habia pensado algo asi:

if (!empty($edif) AND !empty($local) AND !empty($situa))
{
$var1= "SELECT * FROM propiedades WHERE idEdificacion LIKE '%$edif%' AND idLocalidad LIKE '%$local%' AND idSituacion LIKE '%$situa%'";
}
else
{
$sql= "SELECT * FROM propiedades WHERE idEdificacion LIKE '%$edif%'";
}
{
$sql= "SELECT * FROM propiedades WHERE idLocalidad LIKE '%$local%'";
}
{
$sql= "SELECT * FROM propiedades WHERE idSituacion LIKE '%$situa%'";
}

pero aca hay algo que anda mal y no se que sera. Y ademas no se donde ubicarlo :(
Les agradezco desde ya el haber entrado por lomenos a leer mi inconveniente... si me ayudan mejor :P :D

InSa
  #2 (permalink)  
Antiguo 17/03/2005, 16:04
 
Fecha de Ingreso: enero-2004
Ubicación: Salto
Mensajes: 484
Antigüedad: 20 años, 3 meses
Puntos: 2
http://www.programacion.com/php/articulo/adr_buscador/
si bien parece más complicado es mas rapido y estable
Saludos cuidate
__________________
Dios dira que esto no es justo, pero lo sera...
  #3 (permalink)  
Antiguo 17/03/2005, 21:34
 
Fecha de Ingreso: marzo-2005
Mensajes: 10
Antigüedad: 19 años
Puntos: 0
muchas gracias... voy a ver que sale.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:19.