Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class paging {
- private $lim;
- private $now;
- public function __construct()
- {
- $this->lim = 5;
- $this->now = 0;
- }
- public function main($num,$url)
- {
- $jumlahpagging = ceil($num/$this->lim);
- $re = "<ul>";
- $prev_dis = ($this->now - 1 <= 0) ? "disabled" : '';
- $next_dis = ($this->now + 1 > $jumlahpagging) ? "disabled" : '';
- $link_prev = ($this->now - 1 <= 0) ? $url.($this->now - 1) : '#';
- $link_next = ($this->now + 1 <= 0) ? $url.($this->now - 1) : '#';
- $re .= "<li class='$prev_dis'><a href='". $url.($this->now - 1) ."' disabled='$prev_dis'>Sebelumnya</a></li>";
- $re .= "<li class='$next_dis'><a href='". $url.($this->now + 1) ."' $next_dis>Selanjutnya</a></li>";
- $re .= "</ul>";
- return $re;
- }
- public function position($now,$lim)
- {
- $this->lim = $lim;
- $this->now = ($now < 1) ? 0 : $now;
- return ($this->now - 1) * $lim;
- }
- }
- $paging = new paging();
- if(isset($_GET['p'])){
- $paging->position(intval($_GET['p']),10);
- echo "<div class='pagination'>".$paging->main(50,'?p=',intval($_GET['p']))."</div>";
- }
Advertisement
Add Comment
Please, Sign In to add comment