Ver Mensaje Individual
  #7 (permalink)  
Antiguo 30/11/2011, 11:56
cpuser
 
Fecha de Ingreso: diciembre-2005
Ubicación: Mar del Plata
Mensajes: 146
Antigüedad: 19 años, 1 mes
Puntos: 2
Respuesta: Problema con ElseIf y &&

Ahi está, despues de horas de intentos así quedo el código final

Código PHP:
if ($titulo !='' && $categoria !='-- Seleccionar --' && $combustible == 'todos'
    {
    
$buscar mysql_query("SELECT id, titulo, categoria, imagen1
    FROM autos
    WHERE
        titulo = '$titulo' AND
        categoria = '$categoria' AND
        ano BETWEEN $aniodesde AND $aniohasta
    ORDER BY id DESC"
) or die ();
    } 

elseif (
$titulo == '' && $categoria == '' && $combustible !='todos'
    {
    
$buscar mysql_query("SELECT id, titulo, categoria, imagen1
    FROM autos
    WHERE
        combustible = '$combustible' AND
        ano BETWEEN $aniodesde AND $aniohasta
    ORDER BY id DESC"
) or die ();
    }
    
elseif (
$titulo == '' && $categoria == '' && $combustible == 'todos'
    {
    
$buscar mysql_query("SELECT id, titulo, categoria, imagen1
    FROM autos
    WHERE
        ano BETWEEN $aniodesde AND $aniohasta
    ORDER BY id DESC"
) or die ();
    }
    
    
/**/
elseif ($categoria == '-- Seleccionar --' && $combustible == 'todos')
    {
    
$buscar mysql_query("SELECT id, titulo, categoria, imagen1
    FROM autos
    WHERE
        titulo = '$titulo' AND
        ano BETWEEN $aniodesde AND $aniohasta
    ORDER BY id DESC"
) or die ();
    }        
    
/**/
    
elseif ($categoria == '-- Seleccionar --' && $combustible != 'todos'
    {
    
$buscar mysql_query("SELECT id, titulo, categoria, imagen1
    FROM autos
    WHERE
        combustible = '$combustible' AND
        titulo = '$titulo' AND
        ano BETWEEN $aniodesde AND $aniohasta
    ORDER BY id DESC"
) or die ();
    }

else 
    {
    
$buscar mysql_query("SELECT id, titulo, categoria, imagen1
    FROM autos
    WHERE
        titulo = '$titulo' AND
        categoria = '$categoria' AND
        combustible = '$combustible' AND
        ano BETWEEN $aniodesde AND $aniohasta
    ORDER BY id DESC"
) or die ();
    } 
Gracias a todos :)
__________________
Me gusta mucho ver Videos de carros en internet :)