ya mira le aregle variaspifias como comillas que em faltaban y quitar todos los or del if,
peor en cuento a los AND tengo que preguntar si estan vacios si es asi no tomarlos... como hago eso?
Código PHP:
if ($tmp=$_POST['nom_filtro']){
$result=mysql_query("select * from filtros
where nom_filtro = '".$tmp."'
and idpersona = '".$id."' ; ");
while ($row = mysql_fetch_array($result)){
if (campo_filtro == “fase”) $sql1 .= "fase = ".$row[valor_filtro]." OR ";
if (campo_filtro == “sitio”) $sql2 .= "sitio = ".$row[valor_filtro]." OR ";
if (campo_filtro == “zona”) $sql3 .= "zona = ".$row[valor_filtro]." OR ";
}
$sql1 = substr($sql1, 0, strlen($sql1)-3);
$sql2 = substr($sql2, 0, strlen($sql2)-3);
$sql3 = substr($sql3, 0, strlen($sql3)-3);
$nuevaSQL = mysql_query("SELECT * FROM ab WHERE ($sql1) AND ($sql2) AND ($sql3); ")or die( mysql_error() );
while ($tmp = mysql_fetch_array($result)){