Re: finder (I AM REALLY SORRY)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



not quite

if $f_inmueble > 0 is false (<=0) than this will not be part of the search
and the next line will add a AND following the WHERE which is syntax error

so try this:

        $sql_BUSQUEDA = "SELECT * FROM principal FULL JOIN detalles WHERE
1=1 '";  //1=1 is always true

        if ($f_inmueble > 0) { $sql_BUSQUEDA .= " AND inmueble LIKE
'%$f_inmueble%' "; }


2009/7/17 Emiliano Boragina <emiliano.boragina@xxxxxxxxx>

> Sorry a lot of times!!!
>
> Please... tell me (and help me) to know if this is right:
>
>
>
> <?
>
> include "conn.php";
>
>
>
> $sql = "SELECT * FROM principal FULL JOIN detalles FULL JOIN aestrenar FULL
> JOIN fotos ON principal.id=detalles.id=aestrenar.id=fotos.id ORDER BY id
> ASC";
>
> $result=mysql_query($sql,$conn);
>
> $row=mysql_fetch_row($result);
>
>
>
> $f_codigo = $_REQUEST['codigo'];
>
> $f_inmueble = $_REQUEST['inmueble'];
>
> $f_operacion = $_REQUEST['operacion'];
>
> $f_desde = $_REQUEST['fpreciodesde'];
>
> $f_hasta = $_REQUEST['fpreciohasta'];
>
> $f_moneda = $_REQUEST['moneda'];
>
> $f_region = $_REQUEST['region'];
>
> $f_barrio = $_REQUEST['barrio'];
>
> $f_ambientes = $_REQUEST['ambientes'];
>
> $f_dependencia = $_REQUEST['dependencia'];
>
> $f_cochera = $_REQUEST['cochera'];
>
> $f_ubicacion = $_REQUEST['ubicacion'];
>
> $f_apto = $_REQUEST['apto'];
>
>
>
> if(($f_desde <= 0) || ($f_desde == "")) { $f_desde = 0; }
>
> if(($f_hasta <= 0) || ($f_hasta == "")) { $f_hasta = 0; }
>
> if(($f_ambientes <= 0) || ($f_ambientes == "")) { $f_ambientes = 0; }
>
> $f_precio = $f_desde >= $row['precio'] <= $f_hasta;
>
>
>
> if($f_codigo == "")
>
> {
>
>         $sql_BUSQUEDA = "SELECT * FROM principal FULL JOIN detalles WHERE
> '";
>
>         if ($f_inmueble > 0) { $sql_BUSQUEDA .= " inmueble LIKE
> '%$f_inmueble%' "; }
>
>         if ($f_operacion > 0) { $sql_BUSQUEDA .= "AND operacion LIKE
> '%$f_operacion%' "; }
>
>         if ($f_precio) { $sql_BUSQUEDA .= "AND precio = '$f_precio' "; }
>
>         if ($f_moneda == 1) { $sql_BUSQUEDA .= "AND moneda = '$f_moneda' ";
> }
>
>         if ($f_moneda == 2) { $sql_BUSQUEDA .= "AND moneda = '$f_moneda' ";
> }
>
>         if ($f_region > 0) { $sql_BUSQUEDA .= "AND region LIKE
> '%$f_region%' "; }
>
>         if ($f_barrio > 0) { $sql_BUSQUEDA .= "AND barrio LIKE
> '%$f_barrio%' "; }
>
>         if ($f_ambientes > 0) { $sql_BUSQUEDA .= "AND ambientes LIKE
> '%$f_ambientes%' "; }
>
>         if ($f_dependencia > 0) { $sql_BUSQUEDA .= "AND dependencia LIKE
> '%$f_dependencia%' "; }
>
>         if ($f_cochera > 0) { $sql_BUSQUEDA .= "AND cochera LIKE
> '%$f_cochera%' "; }
>
>         if ($f_ubicacion > 0) { $sql_BUSQUEDA .= "AND ubicacion LIKE
> '%$f_ubicacion%' "; }
>
>         if ($f_apto > 0) { $sql_BUSQUEDA .= "AND apto LIKE '%$f_apto%' "; }
>
>         $sql_BUSQUEDA .= " ORDER BY principal.id DESC";
>
>         $result = mysql_query($sql_BUSQUEDA,$conn);
>
> }
>
> else
>
> {
>
>         $sql_BUSQUEDA = "SELECT * FROM principal FULL JOIN detalles WHERE
> codigo = '$f_codigo'";
>
>         $result=mysql_query($sql_BUSQUEDA,$conn);
>
>         $row=mysql_fetch_row($result);
>
> }
>
> ?>
>
>
>
> Thanks a lot!
>
>
>
> +
>  _
>   // Emiliano Boragina _
>   // Diseño & Comunicación //////////////////
> +
>  _
>   // emiliano.boragina@xxxxxxxxx  /
>   // 15 40 58 60 02 ///////////////////////////
> +
>  _
>
>
>
>


-- 
Jack van Zanen

-------------------------
This e-mail and any attachments may contain confidential material for the
sole use of the intended recipient. If you are not the intended recipient,
please be aware that any disclosure, copying, distribution or use of this
e-mail or any attachment is prohibited. If you have received this e-mail in
error, please contact the sender and delete all copies.
Thank you for your cooperation

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux