Posted By

onefastsnail on 05/24/12


Tagged


Versions (?)

pagination


 / Published in: PHP
 

  1. function pagination($total, $per_page, $page, $start){
  2. $requiredPages = ceil($total/$per_page);
  3. $whichPage= $start/$per_page+1;
  4. $start = "-".$per_page;
  5. echo "<ul class='pagination'><li>Page</li>";
  6.  
  7. for ($i = 1; $i <= $requiredPages; $i++) {
  8. $start = $start+$per_page;
  9. if($i==$whichPage){
  10. echo '<li class="active">'.$i."</li>";
  11. }
  12. else {
  13. echo "<li><a href='".SITE_URL.$page."/".$start."'>".$i."</a></li>";
  14. }
  15. }
  16.  
  17. echo "</ul>";
  18. }

Report this snippet  

You need to login to post a comment.