Pagination

    public function summary_logs()
    {
        $data = [];

        $pid = '1020001';

        $logs = $this->resp_care_log_m->logs($pid);

        $pg = $this->paginate($logs);
        //logg($pg);

        $logs = array_slice($logs, $pg['index'], $pg['page_size']);
        $data['logs'] = $logs;

        $this->load->view('site_header');
        $this->load->view('site_navbar', ['path' => 'report']);
        $this->load->view('report/summary_logs', $data);
        $this->load->view('site_footer');
    }

    private function paginate($rows, $page_size=10){
        $page_count = ceil(count($rows) / $page_size);

        $page = $this->input->get('page');
        if($page == false){
            $page = 1;
        }else if($page < 1){
            $page = 1;
        }else if($page > $page_count){
            $page = $page_count;
        }

        $index = ($page - 1) * $page_size;

        $paginate = [
            'page' => $page, 
            'page_size' => $page_size, 
            'page_count' => $page_count, 
            'index' => $index, 
            'total' => count($rows), 
            'prev_page' => $page - 1, 
            'next_page' => $page + 1
        ];

        return $paginate;
    }

View:

<div style="text-align:center">
      <nav aria-label="Page navigation">
        <ul class="pagination">
          <?php if($pg['page'] > 1): ?>
            <li class="page-item"><a class="page-link" href="<?=BASE_URL?>report/summary_logs?page=<?=$pg['prev_page']?>">Previous</a></li>
          <?php endif; ?>

          <?php 
          for($i = 1; $i <= $pg['page_count']; $i++): 
            $class = '';
            if($i == $pg['page']){
              $class = 'active';
            }
          ?>
            <li class="page-item <?=$class?>"><a class="page-link" href="<?=BASE_URL?>report/summary_logs?page=<?=$i?>"><?=$i?></a></li>
          <?php endfor; ?>

          <?php if($pg['page'] < $pg['page_count']): ?>
            <li class="page-item"><a class="page-link" href="<?=BASE_URL?>report/summary_logs?page=<?=$pg['next_page']?>">Next</a></li>
          <?php endif; ?>
        </ul>
      </nav>
    </div>