Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/07/2009, 11:55
Perrin_1
 
Fecha de Ingreso: marzo-2009
Mensajes: 163
Antigüedad: 15 años, 2 meses
Puntos: 0
ayuda con codigo

tengo un problema, en el siguiente codigo php, lo que debe de hacer es realizar una busqueda flitrada en base a 3 cajas de texto que ahi ustedes veran los nombres $bus_nom $bus_apelpat $bus_apelmat pero en el codigo que hago no me realiza el filtro cuando supuestamente se debe de filtrar...mi query me manda TODOS los campos y no los que tengan parecido con la unica caja de texto que se envio..saludos....gracias por su ayuda

Código PHP:
<?php
$bus_nombre
='\''.$_POST['nombre'].'\'';
$bus_apelpat='\''.$_POST['apellido_pat'].'\'';
$bus_apelmat='\''.$_POST['apellido_mat'].'\'';

    if(isset(
$_POST['buscar']))
    {
        unset(
$where);
        
$and=" AND";
        
$c=0;
        
$array = array($bus_nom$bus_apelpat$bus_apelmat);
        
        
$max=count($array);    
        for(
$i=0$i<$max$i++){
        echo 
" $array[0]";
            if((
$_POST[$array[$i]])!=''){
                if(
$c>0)
                    
$union=$and;
                else
                    
$union="";
                
$where.=" $union ".$array[$i]."=".$_POST[$array[$i]]."";
                
$c++;
                
            }
        }
        if(
$c>0)
            
$where="WHERE $where";
        
        
//$query= "SELECT * FROM `cliente_datos` $where ";
        //$resultados = mysql_query($query,$db);
        
        
$query 'SELECT * FROM cliente_datos $where ';
        
$result mysql_query($query) or die ('Error in query: $query. ' mysql_error());
        echo 
" $query " ;
          if (
mysql_num_rows($result) > 0)
        {

            echo 
'<table width=100% cellpadding=0 cellspacing=0 border=1>';
            echo
                 
'<tr><td><b>Folio</b></td><td><b>Nombre</b></td><td><b>Apellido Paterno</b></td><td><b>Apellido Materno</b></td><td></tr>';
// iterate over record set
// print each field
            
while($row mysql_fetch_row($result))
            {
                echo 
'<tr>';
                echo 
'<td>' $row[0] . '</td>';
                echo 
'<td>' $row[1] . '</td>';
                echo 
'<td>' $row[2] . '</td>';
                echo 
'<td>' $row[3] . '</td>';
                echo 
'</tr>';
            }
            echo 
'</table>';
        }
        
    }
    include 
"cerrar_conexion.php";
?>