Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/10/2010, 02:38
albertpg
 
Fecha de Ingreso: enero-2005
Mensajes: 170
Antigüedad: 19 años, 4 meses
Puntos: 0
Búsquedas filtradas

Buenas! Estoy usando el Paginator para paginar mis búsquedas y me va genial, pero ahora quiero aplicar unos filtros antes de realizar la búsqueda.
Será elegir una opción de 2 Select box y escribir en dos campos de texto (elegir provincia, introducir nombre, e-mail i elegir si el usuario está deshabilitado o no).

He hecho lo siguiente:
Código PHP:
Ver original
  1. if ($_POST["SNAYprovincia"] <> 0) {
  2.         if ($Condicion == "") {
  3.             $Condicion = $Condicion ." WHERE clau_provincia = ". $_POST["SNAYprovincia"];
  4.         }else{
  5.             $Condicion = $Condicion ." AND clau_provincia = ". $_POST["SNAYprovincia"];
  6.         }
  7.     }
  8.     if (strlen($_POST["TNAYnom"]) > 0) {
  9.         if ($Condicion == "") {
  10.             $Condicion = $Condicion ." where (nom like '%". str_replace($_POST["TNAYnom"],"'","´") ."%' or cognom1 like '%". str_replace($_POST["TNAYnom"],"'","´") ."%' or cognom2 like '%". str_replace($_POST["TNAYnom"],"'","´") ."%')";
  11.         }else{
  12.             $Condicion = $Condicion &" and (nom like '%". str_replace($_POST["TNAYnom"],"'","´") ."%' or cognom1 like '%". str_replace($_POST["TNAYnom"],"'","´") &"%' or cognom2 like '%". str_replace($_POST["TNAYnom"],"'","´") ."%')";
  13.         }
  14.     }
  15.     if (strlen($_POST["TNAYmail"]) > 0) {
  16.         if ($Condicion == "") {
  17.             $Condicion = $Condicion ." where mail like '%". str_replace($_POST["TNAYmail"],"'","´") ."%'";
  18.         }else{
  19.             $Condicion = $Condicion ." and mail like '%". str_replace($_POST["TNAYmail"],"'","´") ."%'";
  20.         }
  21.     }
  22.     if (strlen($_POST["SNAYdeshabilitat"]) > 0 ){
  23.         if (clng($_POST["SNAYdeshabilitat"]) == 1) {
  24.             if ($Condicion == "") {
  25.                 $Condicion = $Condicion ." where deshabilitat = true";
  26.             }else{
  27.                 $Condicion = $Condicion ." and deshabilitat = true";
  28.             }
  29.         }else{
  30.             if ($Condicion == "") {
  31.                 $Condicion = $Condicion ." where deshabilitat = false";
  32.             }else{
  33.                 $Condicion = $Condicion ." and deshabilitat = false";
  34.             }
  35.         }
  36.     }

Y luego en la consulta:

"SELECT * FROM usuaris '".$Condicion."'"

pero me da error de syntaxis. Como lo véis?