Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/05/2012, 00:34
Avatar de Ex_shadow
Ex_shadow
 
Fecha de Ingreso: febrero-2012
Ubicación: Calera Avellaneda, Buenos Aires, Argentina, Argentina
Mensajes: 95
Antigüedad: 12 años, 2 meses
Puntos: 4
Pregunta Paginacion en php While dentro de funcion?

Hola les explico.
Hice un sistema de paginacion en php el cual esta dentro de una funcion.
Se preguntaran cual es el problema? .El while. Se los muestro y luego les explico.

Código PHP:
Ver original
  1. # --- Conexion mysql
  2. function Conectar ($Host,$Usuario,$Contrasena,$Base){
  3.    
  4.     $Conexion = mysql_connect($Host,$Usuario,$Contrasena);
  5.     return mysql_select_db($Base,$Conexion);
  6.    
  7. }
  8.  
  9. # --- Consulta
  10. function Consulta($Consult){
  11.    
  12.     return mysql_query($Consult);
  13.    
  14. }
  15.  
  16. # --- Reg_Num
  17. function Reg_Num($Consult){
  18.    
  19.     return mysql_num_rows($Consult);
  20.    
  21. }
  22.  
  23. # --- Asooc
  24. function Assoc($Consult){
  25.     return mysql_fetch_assoc($Consult);
  26. }
  27.  
  28. # --- Paginador
  29. function Paginador($Consult,$Reg,$Botones,$Class,$Funcion){
  30.    
  31.     # - Posicion
  32.     if(!isset($_GET['Pag']) || $_GET['Pag']<0){ // Si no Existe Pag o Es menor a 0
  33.         $Pagina = 1;
  34.     }else{
  35.         $Pagina = $_GET['Pag'];
  36.     }
  37.    
  38.     # - Opciones
  39.     $Consulta = Consulta($Consult);
  40.     $Registros = $Reg;
  41.     $Intervalo = $Botones;
  42.    
  43.     # - Configuracion
  44.     $Cantidad = Reg_Num($Consulta);
  45.     $Desde = $Pagina*$Registros;
  46.     $Total = ceil($Cantidad/$Registros);
  47.     $Botones = ($Intervalo*2)+1;
  48.     $i = 0;
  49.     $Func = $Pagina-$Intervalo;
  50.        
  51.     # - Navegacion
  52.     $Anterior = $Pagina-1;
  53.     $Siguiente = $Pagina+1;
  54.    
  55.     # - Bucle
  56.     while($Campo = Assoc($Consulta)){
  57.         echo $Funcion;
  58.     }
  59.    
  60.     # -- Empieza la Navegacion
  61.     # - Boton Anterior
  62.     if($Pagina>1){
  63.         echo '<a href="?Pag='.$Anterior.'"> <input type="button" class="Navegacion" value="Anterior"> </a>';
  64.     }
  65.    
  66.     # - Paginas
  67.     while ($i<$Botones) {
  68.      
  69.         if ($Func>0 and $Func<=$Total) {
  70.    
  71.             if($Func == $Pagina){
  72.                 echo '<input type="button" class="'.$Class.' Disabled" value="'.$Func.'" disabled="disabled"/>';
  73.             }else{
  74.               echo '<a href="?Pag='.$Func.'"> <input type="button" class="'.$Class.'" value="'.$Func.'" />  </a>';
  75.             }
  76.          $i++;
  77.         }
  78.    
  79.             if($Func>$Total){
  80.                 $i=$Botones;
  81.             }
  82.          $Func++;
  83.         }
  84.    
  85.     /* Simple
  86.     echo $Pagina.' / '.$Total;*/
  87.  
  88.     # - Boton Siguiente
  89.     if($Pagina>=1 and $Pagina<$Total || !isset($_GET['Pag'])){
  90.         echo '<a href="?Pag='.$Siguiente.'"> <input type="button" class="Navegacion" value="Siguiente"> </a>';
  91.     }  
  92. }
Acá lo único que pido son 5 parametros:

El 1: La consulta a paginar. - OK
El 2: La cantidad de registros por pagina. - OK
El 3: El Intervalo de botones ( 12 13 14) = (3). - OK
El 4: Las clases de los botones. - OK
El 5: El while en una funcion. - NO


Código PHP:
Ver original
  1. <?
  2.             include("Includes/Paginador.php");
  3.            
  4.             function Mostrador(){
  5.                 return $Campo['help_topic_id'];
  6.                
  7.             }
  8.            
  9.             Conectar('localhost','root','','mysql');
  10.            
  11.             Paginador("SELECT * FROM help_relation",20,2,'Paginas',Mostrador());
  12.         ?>

1 - No me tira ningun error
2 - Me muestra los botones como deven estar
3 - Pero no me muestra los Registros