Ver Mensaje Individual
  #4 (permalink)  
Antiguo 04/09/2013, 02:08
Novato2013
 
Fecha de Ingreso: junio-2013
Ubicación: Madrid
Mensajes: 61
Antigüedad: 10 años, 10 meses
Puntos: 5
Respuesta: Paginación con filtros casi acabada, pequeño fallito q me atasca

Cita:
Iniciado por p414 Ver Mensaje
o si deseas usar a fuerzas el valor de $_POST puedes alojarlo en una input type ="hidden" e ir lo pasando mediante un submit de un form (lo veo más complejo)

Como bien lo comentas usa sessiones o bien usa $_GET para ir pasando el número de la paginación.
Lo primero: Muchas gracias por responder.

A ver si me aclaro un poko mejor, q con sto d intentar aprender rápido PHP no veas q lio tengo ya:

Si no me equivoco, con mi paginador estoy intentando hacer exactamente lo que me dices, usar el $_GET para ir pasando el número de la paginación:

Código PHP:
Ver original
  1. <div class="text_align_left" >
  2.                                 <?php    
  3.                                 //Print previous
  4.                                 if (($total_pages > 1) AND ($getPage > 1 )) {
  5.                                     echo "<a href ='{$_SERVER['PHP_SELF']}?page=".($getPage-1)."'>" .$arrMainPage[$MainPagePrevious]['TextHeader']. "</a> ";
  6.                                 }  
  7.                                
  8.                                 //If current page is < 5 the list start in 1 if not, in current page - 5
  9.                                 if ($getPage < 5) {
  10.                                     $StartList = 1;
  11.                                 } else {
  12.                                     $StartList = $getPage - 5;
  13.                                 }
  14.  
  15.                                 // If current page is very near of total_pages, StartList = $total_pages - 10;
  16.                                 if ((($getPage + 5) > $total_pages) AND ($total_pages >1)) {
  17.                                     $StartList = $total_pages - 10;
  18.                                 }
  19.                                
  20.                                 //New if
  21.                                 //if (($getPage == $total_pages) AND ($total_pages<2)){
  22.                                 if (($total_pages < 0) OR ($getPage < 0)){
  23.                                     echo "1";
  24.                                 }else{
  25.                                 //This for was out of the new if
  26.                                     for($cont = $StartList; $cont <= $StartList + 10; $cont++){
  27.                                         if ($cont == $getPage) {
  28.                                             echo "<a class='bold' href ='{$_SERVER['PHP_SELF']}?page=".$cont."'>$cont</a> ";
  29.                                         } else {
  30.                                             if($total_pages > 1){
  31.                                                 echo "<a href ='{$_SERVER['PHP_SELF']}?page=".$cont."'>$cont</a> ";
  32.                                             }  
  33.                                         }
  34.                                     }
  35.                                 }  
  36.                                                
  37.                                 if(($getPage < $total_pages) AND ($total_pages > 1 )){
  38.                                     echo "<a href ='{$_SERVER['PHP_SELF']}?page=".($getPage+1)."'>" .$arrMainPage[$MainPageNext]['TextHeader']. "</a> ";
  39.                                 }
  40.                                 ?>
  41.                             </div>

Si te fijas tengo la variable $getPage por todos lo lados del paginador, la cual he declarado más arriba usando $_GET , te pongo el resto d variables d la paginación tb aparte de $getPage:

Código PHP:
Ver original
  1. $SetNumberOnPage = $NumberOnPage;
  2.  
  3. if (isset($_GET['pagenum'])){
  4.     $SetNumberOnPage = $_GET['pagenum'];
  5. }
  6.  
  7. //$beginning = $Page;
  8. $getPage = $Page;
  9.  
  10. if (isset($_GET['page'])) {
  11.     $getPage = $_GET['page'];
  12. }
  13. /*
  14. else{
  15.     $getPage = 1;
  16. }
  17. */
  18. $rcsElementNumber = $elementdata->query($qryElementNumber);
  19. $row = $rcsElementNumber->fetch_array(MYSQLI_BOTH);
  20.  
  21. $total_pages = floor($row["ElementCount"]/$SetNumberOnPage)+1;
  22.  
  23. if(is_numeric($getPage)){
  24.     if($getPage > $total_pages){
  25.         $getPage = $total_pages;
  26.     }
  27.     $beginning = (($getPage - 1) *$SetNumberOnPage);
  28. } else {
  29.     $beginning = 0;
  30. }

Con lo cual se supone que estoy usando $_GET cada vez que clicleo en un número de la paginación no?, o al menos eso es lo que pretendía...

Muchas gracias.