Codeigniter Pagination Status

    function paging_status(){
      
        $num_pages = ceil($this->total_rows / $this->per_page);
      
        if ($this->total_rows == 0) { return ''; }
      
        if ($this->cur_page == 0){ $this->cur_page = 1; }
      
        if ($this->total_rows == 1){
          
             return $status = 'FOUND: '.$this->total_rows.' RECORD(S) ON '.$num_pages.' PAGE(S). DISPLAYED: RECORD(S) 1 TO 1.';
        }
      
        if (!$this->total_rows) {
          $first = 0;
        }
        else {
          $first = $this->per_page * $this->cur_page - $this->per_page + 1;
        }
      
        if (!$this->total_rows) {
          $last = 0;
        }
        elseif ($this->cur_page == $num_pages) {
          $last = $this->total_rows;
        }
        else {
          $last = $this->per_page * $this->cur_page;
        }

        $status = 'FOUND: '.$this->total_rows.' RECORD(S) ON '.$num_pages.' PAGE(S). DISPLAYED: RECORD(S) '.$first.' TO '.$last.'.';
      
        return $status;
    }


echo "<br />".$this->pagination->paging_status();







Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

0 comments: on "Codeigniter Pagination Status"

:) ) ;) ) ;;) :D ;) :p :( ( :) :( :X =(( :-o :-/ :-* :| 8-} :) ] ~x( :-t b-( :-L x( =))
Post a Comment