943,582 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1405
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Sep 19th, 2009
0

Re: How to use large pagination in a limited area

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:
PHP Syntax (Toggle Plain Text)
  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>

php Syntax (Toggle Plain Text)
  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.
Reputation Points: 7
Solved Threads: 14
Junior Poster
smartness is offline Offline
103 posts
since Aug 2007
Sep 19th, 2009
-1

Re: How to use large pagination in a limited area

plz , i am waiting for some help . Please............
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vijaysoft1 is offline Offline
81 posts
since Jun 2008
Sep 19th, 2009
0

Re: How to use large pagination in a limited area

Look at the post above yours mate! i posted the code, didn't it work????
Reputation Points: 7
Solved Threads: 14
Junior Poster
smartness is offline Offline
103 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Help debug Random property script.
Next Thread in PHP Forum Timeline: Search from text box and saving to txt file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC