Ver Mensaje Individual
  #3 (permalink)  
Antiguo 27/06/2009, 19:48
Avatar de xempro
xempro
 
Fecha de Ingreso: marzo-2007
Ubicación: Chile
Mensajes: 222
Antigüedad: 17 años, 1 mes
Puntos: 6
Respuesta: generar consultas filtradas

Prueba lo siguiente...

Código PHP:
<?php
    
if(isset($_POST['buscar'])){
        unset(
$where);
        
$and=" AND";
        
$c=0;
        
$array = array('bus_folio','bus_nom','bus_apelpat','bus_apelmat');
        
$max=count($array);
        for(
$i=0$i<$max$i++){
            if(
strlen($_POST[$array[$i]])>0){
                if(
$c>0)
                    
$union=$and;
                else
                    
$union="";
                
$where.="$union ".$array[$i]."='".$_POST[$array[$i]]."'";
                
$c++;
            }
        }
        if(
$c>0)
            
$where="WHERE $where";
        echo 
"<b>Resultado = SELECT * FROM tabla $where</b>";
    }
?>