Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/01/2006, 04:08
Avatar de pereztroff
pereztroff
 
Fecha de Ingreso: junio-2002
Ubicación: En la Internet.
Mensajes: 4.068
Antigüedad: 21 años, 10 meses
Puntos: 5
0 registros en consulta

No entiendo que puede pasar con un formulario de consulta que hice, funciona cuando quiere. A ver si alguien me puede orientar porque me quede estancado en este problema. Gracias.
TEngo un formulario que recoge varios valores:
Código PHP:
<table width="140" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td> 
      <form name="form3" method="post" action="buscador2.php">
        <table width="130" border="0" cellspacing="0" cellpadding="2" align="center">
          <tr> 
            <td> 
              <? 
                          
  $Resultado
=mysql_query("select categoria,categoria from categorias ORDER BY categoria");
  echo 
"<SELECT name='categoria' class='tex_menu' style='background-color: #eeeeee; color: #000000; border: 1 solid #000000'>\n";
  echo 
"<OPTION value=''>-› propiedad</OPTION> \n" ;
  while(
$arr mysql_fetch_row ($Resultado))
      {
      if (
$seccion == $arr[0])
         print(
"<option value=$arr[0] selected >$arr[1]</option> \n");
      else
         print(
"<option value='$arr[0]'>$arr[1]</option>\n");
      }

  echo 
" </SELECT>\n"

?>
            </td>
          </tr>
          <tr> 
            <td> 
              <select name="tipo" class="tex_menu" style='background-color: #eeeeee;  border: 1 solid #000000'>
                <option value="venta" selected>Venta </option>
                <option value="alquiler"> Alquiler </option>
              </select>
            </td>
          </tr>
          <tr> 
            <td> 
              <div align="left" class="tex_menu"> desde <? echo $SITE_moneda?>
                <input type="text" name="precio1" class="tex_marron1" size="8" style="background-color: #eeeeee; color: #000000; border: 1 solid #000000" value="0">
              </div>
            </td>
          </tr>
          <tr> 
            <td> 
              <div align="left"> <font class="tex_menu">hasta <? echo $SITE_moneda?></font> 
                <input type="text" name="precio2" class="tex_marron1" size="8" style="background-color: #eeeeee; color: #000000; border: 1 solid #000000" value="0">
              </div>
            </td>
          </tr>
          <tr> 
            <td> 
              <div align="center"> </div>
            </td>
          </tr>
          <tr> 
            <td> 
              <div align="center"> 
                <input type="submit" value="Buscar" name="B122"
  style="BORDER: rgb(0,0,0) 1px solid; FONT-SIZE: 8pt; FONT-FAMILY: Verdana; 
         BACKGROUND-COLOR: rgb(238,238,238)">
              </div>
            </td>
          </tr>
        </table>
        </form>
pero cuando estos valores recogidos van a buscador2.php no tiene en cuenta las condiciones de seleccion y no muestra registros, aunque en verdad si los hay:
Código PHP:
$pegar "SELECT * FROM propiedades WHERE categoria='$categoria' AND tipo='$tipo' AND (precio >= '$precio1') AND (PRECIO <= '$precio2')  LIMIT $inicial,$cantidad";
$cad mysql_db_query($base_dato,$pegar) or die (mysql_error());
$total_records mysql_num_rows($cad); 
Si imprimo el numero de registros cuyo valor de precio este comprendido entre ambos no muestra nada, puse un echo $total_records;
echo "<br>"; y muestra valor 0

Tendria que listarme todos los registros que cumplen la condicion para este fin uso este codigo:
Código PHP:
while($array mysql_fetch_array($cad)) {

     
$precio trim(number_format($array['precio'], 0',''.'));
    
$foto=trim($array['foto']);   

 if (empty(
$foto)) { 
   
$foto='sinfoto.gif';}
  echo 
"<tr><td><a href='detalle_propiedad.php?id=$array[id]'><img src='fotos/$foto' align='left' width='70' border='0'></a><font class='tex_marron1'>Ubicación: <b>$array[ubicacion]</b><br>Precio:<b>$precio $SITE_moneda </b><br><img src='imagenes/cuadraditomas.gif'> <a class='tex_menu' href='detalle_propiedad.php?id=$array[id]'>ver detalles</a></b></font></td></tr>";


¿que esta fallando?