How to use large pagination in a limited area

Reply

Join Date: Aug 2007
Posts: 72
Reputation: smartness is an unknown quantity at this point 
Solved Threads: 10
smartness's Avatar
smartness smartness is offline Offline
Junior Poster in Training

Re: How to use large pagination in a limited area

 
0
  #11
Sep 19th, 2009
Currently, when you're on Page 9, the link is displayed like this:

«« First « Prev 6 7 8 9 10 11 12 13 14 Next » Last »»

This is better, cuz the visitor will have the last 3 previous page, and the next 5 pages...
So You want this:
«« First « Prev 9 10 11 12 13 14 15 16 17 Next » Last »»

When you're on page9 right?

EDIT{}

Here:
  1. <style type="text/css">
  2. .pagination{
  3. padding: 2px;
  4. }
  5. .pagination ul{
  6. margin: 0;
  7. padding: 0;
  8. text-align: left; /*Set to "right" to right align pagination interface*/
  9. font-size: 16px;
  10. }
  11. .pagination li{
  12. list-style-type: none;
  13. display: inline;
  14. padding-bottom: 1px;
  15. }
  16. .pagination a, .pagination a:visited{
  17. padding: 0 5px;
  18. border: 1px solid #9aafe5;
  19. text-decoration: none;
  20. color: #2e6ab1;
  21. }
  22. .pagination a:hover, .pagination a:active{
  23. border: 1px solid #2b66a5;
  24. color: #000;
  25. background-color: #FFFF80;
  26. }
  27. .pagination a.currentpage{
  28. background-color: #2e6ab1;
  29. color: #FFF !important;
  30. border-color: #2b66a5;
  31. font-weight: bold;
  32. cursor: default;
  33. }
  34. .pagination a.disablelink, .pagination a.disablelink:hover{
  35. background-color: white;
  36. cursor: default;
  37. color: #929292;
  38. border-color: #929292;
  39. font-weight: normal !important;
  40. }
  41. .pagination a.prevnext{
  42. font-weight: bold;
  43. }
  44. </style>

  1. <?php
  2. if(isset($_GET["page"])) {
  3. $page = $_GET["page"];
  4. } else {
  5. $page = 1;
  6. }
  7. $totalPages = 50;
  8. function paging($page, $totalPages) {
  9. $printPages = 9; //Show only X pages
  10. $i = 1;
  11. $previous_page = ($page > 1) ? $page - 1 : 1;
  12. $next_page = $page + 1;
  13. if($totalPages < $printPages) {
  14. $printPages = $totalPages;
  15. }
  16. echo '<div class="pagination" align="center">
  17. <ul>';
  18. if($page > 1) {
  19. echo ' <li><a href="?page=1">&laquo;&laquo; First</a></li> ';
  20. echo ' <li><a href="?page='.$previous_page.'">&laquo; Prev</a></li> ';
  21. if($totalPages > 0) {
  22. //Nothing for now, used to have a | separator here
  23. }
  24. }
  25.  
  26. if($page - $printPages <= 0)
  27. {
  28. $currentPage = 1;
  29. }
  30. elseif($page > 3 && $page + ($printPages -1) < $totalPages)
  31. {
  32. $currentPage = $page;
  33. }
  34. else
  35. {
  36. $currentPage = $totalPages - ($printPages - 1);
  37. }
  38.  
  39.  
  40. while($i <= $printPages)
  41. {
  42. echo '<li><a';
  43. if($page == $currentPage) {
  44. echo ' class="currentpage" ';
  45. }
  46. echo ' href="?page='.$currentPage.'"> '.$currentPage.' </a></li>&nbsp;';
  47. $currentPage++;
  48. $i++;
  49. }
  50.  
  51. if($page < $totalPages)
  52. {
  53. $next = $page + 1;
  54. echo '&nbsp;<li><a href="?page='.$next.'">Next &raquo;</a></li> ';
  55. echo ' <li> <a href="?page='.$totalPages.'">Last &raquo;&raquo;</a></li> ';
  56.  
  57. }
  58. echo '</ul></div>';
  59. }
  60.  
  61. //Use it
  62. paging($page, $totalPages)
  63. ?>
Last edited by smartness; Sep 19th, 2009 at 6:57 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 64
Reputation: vijaysoft1 is an unknown quantity at this point 
Solved Threads: 0
vijaysoft1's Avatar
vijaysoft1 vijaysoft1 is offline Offline
Junior Poster in Training

Re: How to use large pagination in a limited area

 
-1
  #12
Sep 19th, 2009
plz , i am waiting for some help . Please............
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 72
Reputation: smartness is an unknown quantity at this point 
Solved Threads: 10
smartness's Avatar
smartness smartness is offline Offline
Junior Poster in Training

Re: How to use large pagination in a limited area

 
0
  #13
Sep 19th, 2009
Look at the post above yours mate! i posted the code, didn't it work????
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC