Foros del Web » Programando para Internet » PHP »

Sugerencias de alguna clase para paginar busqueda

Estas en el tema de Sugerencias de alguna clase para paginar busqueda en el foro de PHP en Foros del Web. Hola amigos, necesito de su ayuda/guia, lo q necesito es paginar resultados de busqueda de acuerdo a criterios/filtros, estoy trabajando con php5 y con posgres ...
  #1 (permalink)  
Antiguo 27/05/2009, 22:03
 
Fecha de Ingreso: diciembre-2007
Mensajes: 385
Antigüedad: 16 años, 4 meses
Puntos: 0
Sugerencias de alguna clase para paginar busqueda

Hola amigos, necesito de su ayuda/guia, lo q necesito es paginar resultados de busqueda de acuerdo a criterios/filtros, estoy trabajando con php5 y con posgres 8.2, les pediria porfavor si me pueden sugerir alguna clase o trozo de codigo facil de manejar para implementarlo y lograr hacer la paginacion deacuerdo a determinados criterios/filtros, se lo agradeceria mucho amigos, de antemano gracias.... bye....
  #2 (permalink)  
Antiguo 27/05/2009, 22:06
Avatar de acoevil  
Fecha de Ingreso: julio-2008
Ubicación: localhost/colombia/sevillaValle.php
Mensajes: 1.123
Antigüedad: 15 años, 9 meses
Puntos: 32
Respuesta: Sugerencias de alguna clase para paginar busqueda

Q tal mira esta clase quizas la puedas adaptar a tus necesidades particulares

http://www.forosdelweb.com/f18/aport...naevil-702554/


Suerte!!
  #3 (permalink)  
Antiguo 27/05/2009, 23:04
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 11 meses
Puntos: 1517
Respuesta: Sugerencias de alguna clase para paginar busqueda

Si quieres puedes usar tambien este

Código PHP:
<?php 
class paginationClass
    var 
$page_num 1
    var 
$page_pagination
    var 
$r_comment
    var 
$row_num
    var 
$numofpages
    var 
$range_min
    var 
$range_max;  
    var 
$page_min;  
    var 
$page_max;  

    var 
$range
    var 
$rowsPerPage
    var 
$s_comment
    var 
$s_comment_n
     
    function 
paginationClass($r$rPP$sc$scn){ 
        
$this->range $r
        
$this->rowsPerPage $rPP
        
$this->s_comment $sc
        
$this->s_comment_n $scn
    } 

    private function 
setComment(){ 
        
$this->page_num = (empty($this->page) ? $this->page_num $this->page); 
        
$offset = ($this->page_num 1) * $this->rowsPerPage
        
$this->s_comment $this->s_comment " LIMIT $offset, " $this->rowsPerPage
        
$this->r_comment mysql_query($this->s_comment) or die(mysql_error()); 
        
$r_comment_n mysql_query($this->s_comment_n) or die(mysql_error()); 
        
$this->row_num mysql_num_rows($r_comment_n); 
    } 

    private function 
setValues(){ 
        
$this->numofpages ceil($this->row_num/$this->rowsPerPage); 
        if(
$this->numofpages 1){ 
            
$this->range_min = ($this->range == 0) ? ($this->range 2) -: ($this->range 1) / 2
            
$this->range_max = ($this->range == 0) ? $this->range_min $this->range_min;  
            
$this->page_min $this->page_num $this->range_min;  
            
$this->page_max $this->page_num $this->range_max;  

            
$this->page_min = ($this->page_min 1) ? $this->page_min;  
            
$this->page_max = ($this->page_max < ($this->page_min $rthis->ange 1)) ? $this->page_min $this->range $this->page_max;  
            if (
$this->page_max $this->numofpages){  
                
$this->page_min = ($this->page_min 1) ? $this->numofpages $this->range 1;  
                
$this->page_max $this->numofpages;  
            } 
            
$this->page_min = ($this->page_min 1) ? $this->page_min;  
        } 
    } 

    private function 
setPagePagination(){ 
        
$self $_SERVER["PHP_SELF"]; 
        if(
$this->numofpages 1){ 
            
$setPP "<div>"

            
//[ « ] 
            
if (($this->page_num > ($this->range $this->range_min)) && ($this->numofpages $this->range)){  
                
$setPP .= "[ <a title='First' href='".$self."?page=1' class='title'><b>&laquo;</b></a> ]\n";  
            } 

            
// [ Previous # ] 
            
if ($this->page_num != 1) {  
                
$setPP .= "[ <a title='First' href='".$self."?page=".($this->page_num-1)."' class='title'><b>Anteriores " $this->rowsPerPage "</b></a> ]\n";  
            }  

            
// ... 
            
if (($this->page_num > ($this->range $this->range_min)) && ($this->numofpages $this->range)){  
                
$setPP .= " <b>...</b> ";  
            } 

            
// [ # ] 
            
for ($i $this->page_min$i <= $this->page_max$i++) {  
                if (
$i == $this->page_num)  
                    
$setPP .= "[ <b><font color=red>" $i "</font></b> ]\n";  
                else  
                    
$setPP .= "[ <a href='" .$self"?page=" .$i"' class='title'>".$i."</a> ]\n";  
            }  

            
// ... 
            
if (($this->page_num< ($this->numofpages $this->range_max)) && ($this->numofpages $this->range)) {  
                
$setPP .= " <b>...</b> ";  
            } 

            
//[ Next # ] 
            
if ($this->page_num $this->numofpages) {  
                
$setPP .= "[ <a href='".$self."?page=".($this->page_num 1) . "' class='title'><b>Siguientes " $this->rowsPerPage "</b></a> ]\n";  
            }  

            
//[ » ] 
            
if (($this->page_num< ($this->numofpages $this->range_max)) && ($this->numofpages $this->range)) {  
                
$setPP .= "[ <a title='Last Info' href='".$self."?page=".$this->numofpages"' class='title'><b>&raquo;</b></a> ]\n";  
            } 

            
$setPP .= "</div>"

            
$this->page_pagination $setPP
        } 
    } 

    function 
getPagePagination(){ 
        
$this->setComment(); 
        
$this->setValues(); 
        
$this->setPagePagination(); 
        return array(
'r_comment' => $this->r_comment,  
            
'row_num' => $this->row_num,  
            
'page_pagination' => $this->page_pagination);  
    } 


function 
pagination($r$rPP$sc$scn){ 
    
$p = new paginationClass($r$rPP$sc$scn); 
    foreach(
$p->getPagePagination() as $k => $v){ 
        if(
trim($v)){ 
            global $
$k
            $
$k $v
        } 
    } 

?>

Código PHP:
sql_que_quiero_verificar "SELECT * FROM TABLA"

$sql_que_verificara_numero_de_lineas "SELECT * FROM TABLA"


/* 
El primero es para que me muestre el rango que quiero mostrar 
El segundo es para que me muestre cuantos "Rows" quiero que muestre 
El tercero es mi sql principal 
El cuarto es para ver cuantos "Rows" tiene la tabla seleccionada 
*/ 
pagination(1010$sql_que_quiero_verificar$sql_que_verificara_numero_de_lineas); 

while(
$row mysql_fetch_assoc($r_comment)){ 
  
//codigo que quieras usar 
  
echo $page_pagination

Usa el mas que te guste
  #4 (permalink)  
Antiguo 27/05/2009, 23:05
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 11 meses
Puntos: 1517
Respuesta: Sugerencias de alguna clase para paginar busqueda

Puedes usar el de acoevil como el que te envie el mas que te guste
  #5 (permalink)  
Antiguo 27/05/2009, 23:40
 
Fecha de Ingreso: diciembre-2007
Mensajes: 385
Antigüedad: 16 años, 4 meses
Puntos: 0
Respuesta: Sugerencias de alguna clase para paginar busqueda

Hola abimaelrc, gracias por tu respuesta, pero donde estan los otros dos select restantes q señalas en los comentarios???.... porfavor si me los puedes indicar te lo agradeceria, gracias y gracias de antemano
  #6 (permalink)  
Antiguo 27/05/2009, 23:49
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 11 meses
Puntos: 1517
Respuesta: Sugerencias de alguna clase para paginar busqueda

Como que los dos select restantes? estan ahi mismo declarados

$sql_que_quiero_verificar = "SELECT * FROM TABLA";

$sql_que_verificara_numero_de_lineas = "SELECT * FROM TABLA";
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:10.