bootstrap 3 pagination with codeigniter
Here is Mine, and It Works Using Bootstrap 3
<?php if(!defined('BASEPATH')) exit('Direct Access Not Allowed');
/* This Application Must Be Used With BootStrap 3 * */
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
// end of file Pagination.php
// Location config/pagination.php
// By @emanisof
1) Controlller
$this->load->library('pagination');
$config = [
'base_url' => base_url('admin/deactiveUser'),
'per_page' => 10,
'total_rows' => $this->AdminModel->num_rows(),
];
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['num_tag_open'] = '<li class="page-item">';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="page-item active"><a class="page-link" href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['next_tag_open'] = '<li class="page-item">';
$config['next_tagl_close'] = '</a></li>';
$config['prev_tag_open'] = '<li class="page-item">';
$config['prev_tagl_close'] = '</li>';
$config['first_tag_open'] = '<li class="page-item disabled">';
$config['first_tagl_close'] = '</li>';
$config['last_tag_open'] = '<li class="page-item">';
$config['last_tagl_close'] = '</a></li>';
$config['attributes'] = array('class' => 'page-link');
$this->pagination->initialize($config); // model function
$seeker = $this->AdminModel->seekerlist($config['per_page'], $this->uri->segment(3)); // list of seeker
2)Model
public function seekerlist($limit,$offset) {
$query = $this->db->select('*')
->from('user')
->limit($limit,$offset)
->get();
return $query->result_array();
}
public function num_rows()
{
$query = $this->db->select('*')
->from('user')
->get();
return $query->num_rows();
}
3)View
<tbody>
<?php foreach ($seeker as $seekerData): ?>
<tr>
<td class="checkbox-column">
<img width="30" height="30" src="<?= base_url("uploads/{$seekerData['picpath']}"); ?>"/>
</td>
<td><?php echo ucfirst($seekerData['firstName']) . ' ' . ucfirst($seekerData['lastName']); ?></td>
<td><?php echo $seekerData['currentJobTitle']; ?></td>
<td><?php echo $seekerData['email']; ?></td>
<td><?php echo $seekerData['mobileNum']; ?></td>
<td><?php echo $seekerData['nationality']; ?></td>
<td><span class="label label-danger">Deactive</span></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?= $this->pagination->create_links() ?>