Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/09/2011, 10:50
thehack
 
Fecha de Ingreso: abril-2010
Mensajes: 151
Antigüedad: 14 años
Puntos: 1
Buscador php ajax

hola chicos foros del web tengo un buscador en php y ajax aca el ejemplo del buascador http://mis-algoritmos.com/how-to-cre...ax-live-search

este mi codigo de busqueda

Código PHP:
  public function BuscarNac(){
    
        
    if(isset(
$_GET['page']) and is_numeric($_GET['page']) and $this->page $_GET['page'])
        
$limit " LIMIT ".(($this->page-1)*$this->items).",$this->items";
    else
        
$limit " LIMIT $this->items";
        
       if(isset(
$_GET['q']) and !preg_match('/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i',$_GET['q'])){
        
$q $this->Util->setSecure($_GET['q']); //para ejecutar consulta
        
$busqueda htmlentities($q); //para mostrar en pantalla
$sqlStr $this->ejecutarConsulta("SELECT
m.d_cedula_madre,
p.dp_cedula_padre
FROM
datos_madre AS m
Inner Join datos_padre AS p ON p.dp_id_folio = m.d_id_folio
WHERE
m.d_cedula_madre =  LIKE '%$q%' AND
p.dp_cedula_padre =  LIKE '%$q%'"
) or die(mysql_error());
        
$sqlStrAux $this->ejecutarConsulta("SELECT count(*) as total FROM datos_padre WHERE dp_cedula_padre LIKE '%$q%'");
    }else{
        
$sqlStr $this->ejecutarConsulta("SELECT * FROM datos_padre, datos_madre");
        
$sqlStrAux $this->ejecutarConsulta("SELECT count(*) as total FROM datos_padre ");
    }
     
        
$aux=  $this->fetch_assoc($sqlStrAux);
     
       echo
'<p>';
if(
$aux['total'] and isset($busqueda)){
                echo 
"{$aux['total']} Resultado".($aux['total']>1?'s':'')." que coinciden con tu b&uacute;squeda \"<strong>$busqueda</strong>\".";
            }elseif(
$aux['total'] and !isset($q)){
                echo 
"Total de registros: {$aux['total']}";
            }elseif(!
$aux['total'] and isset($q)){
                echo
"No hay registros que coincidan con tu b&uacute;squeda \"<strong>$busqueda</strong>\"";
            }
        echo
'</p>';                
                        
     if(
$aux['total']>0){
            
$p = new pagination;
            
$p->Items($aux['total']);
            
$p->limit($this->items);
            if(isset(
$q))
                    
$p->target("/buscar/?q=".urlencode($q));
                else
                    
$p->target("/buscar/");
            
$p->currentPage($this->page);
            
$p->show();
            echo 
"\t<table class=\"registros\">\n";
            echo 
"<tr class=\"titulos\"><td>Titulo</td></tr>\n";
            
$r=0;
            while(
$row $this->fetch_assoc($sqlStr)){
          echo 
"\t\t<tr class=\"row$r\"><td><a href=\"http://www.mis-algoritmos.com/?p={$row['dp_id_folio']}\" target=\"_blank\">".htmlentities($row['dp_cedula_padre'])."</a></td></tr>\n";
          if(
$r%2==0)++$r;else--$r;
        }
            echo 
"\t</table>\n";
            
$p->show();
        }   
    } 
me da este error quien puede ayudarme
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE '%56%' AND p.dp_cedula_padre = LIKE '%56%'' at line 8

Gracias y saludos de antemano

Última edición por thehack; 05/09/2011 a las 10:55 Razón: mal el codigo