Guest User

Untitled

a guest
Jul 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <?php
  2. function paginate( $total, $perpage )
  3. {
  4. $current = $_GET['page'] != '' ? $_GET['page'] : 1;
  5.  
  6. $paginate = '<div>';
  7. $paginate .= $current > 1 ? '<a href="?page='.($current-1).'"> &laquo; Older |</a>' : '';
  8. $paginate .= '<div>';
  9.  
  10. for($i = 1; $i <= round($total/$perpage); $i++ ){
  11. $paginate .= '<a href="?page='.$i.'">'.$i."</a>";
  12. }
  13.  
  14. $paginate .= '</div>';
  15. $paginate .= $current <= ($total/$perpage) ? '<a href="?page='.($current+1).'"> | Newer &raquo;</a>' : '';
  16. $paginate .= '</div>';
  17.  
  18. return $paginate;
  19. }
  20. ?>
Add Comment
Please, Sign In to add comment