I'm trying to make a pagination for a query. I can't figure why is the reason that the pagination doesn't work, it shows the pagination links, right now I have 15 records and I want to show that in batches of 5, but in the page # 1 I see the 15 records and when I click in the second page link I have an error that says that the page doesn't exist.
This is my model "searchCases":
//Function to get the active cases
function getCases(){
$query = $this->db->
select('*')->
from('customer_complaint')->
where('active', 1)->
get();
return $query->result();
}
//Function to get the number of opened cases
function countCases(){
$query = $this->db->
select('*')->
from('customer_complaint')->
where('active', 1)->
get();
return $query->num_rows();
}
// Function to retrieve a list of all the records of the table an the params $limit and $start to
// determine the number of records to return and what record to start from.
function fetchCases($limit, $start){
$this->db->limit($limit, $start);
$query = $this->db->
select('*')->
from('customer_complaint')->
where('active', 1)->
get();
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}
}
Now this is my Controller "opened_cases":
public function index(){
$this->load->view('headers');
$this->load->view('navbar');
$data['query'] = $this->searchCases->getCases();
$config['base_url'] = base_url().'index.php/opened_cases/';
$config['total_rows'] = $this->searchCases->countCases();
$config['per_page'] = 5;
$config['uri_segment'] = 2;
$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>";
$this->pagination->initialize($config);
$page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
$data["results"] = $this->searchCases->
fetchCases($config["per_page"], $page);
$this->load->view('opened_cases', $data);
$this->load->view('footer');
}
and my View "opened_cases":
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">Search Results:
</div><!--End of Panel Heading-->
<div class="panel-body">
<table class="table" style="text-align: center">
<tr>
<td>Case ID</td>
<td>Received Date</td>
<td>Folio</td>
<td>Transactions Date</td>
<td>Reason of Complaint</td>
<td>Source of Complaint</td>
<td>Files</td>
</tr>
<?php
foreach ($query as $row) {?>
<tr>
<td><?= $row->complaint_id?></td>
<td><?= date('m/d/Y', strtotime($row->received_date))?></td>
<td><?= $row->folio?></td>
<td><?= date('m/d/Y', strtotime($row->tx_date))?></td>
<?php
$this->load->model('searchCases');
$id=$row->complaint_id;
$reason_id=$this->searchCases->reason($id);
$source_id=$this->searchCases->source($id);
foreach ($reason_id as $rsn) {
if($rsn->reason == 'Others'){
echo "<td class='text-left'>".$rsn->reason.": ".$row->other_reason."</td>";
}else{
echo "<td class='text-left'>".$rsn->reason."</td>";
}
}
foreach ($source_id as $src) {
echo "<td>".$src->source."</td>";
}
?>
<td><?php
$folder = $row->complaint_id;
$path_root = "upload/".$folder."/";
$dir = scandir($path_root, 1);
$array_lenght = count($dir)-2;
if($array_lenght>=1){?>
<span class="glyphicon glyphicon-paperclip"></span>
<?php } ?></td>
</tr>
<?php }?>
</table>
</div><!--End of body panel-->
<div class="panel-footer text-center">
</div><!--End of Panel Footer-->
</div><!--End of Panel-->
<div class="col-sm-12 text-center">
<?= $this->pagination->create_links() ?>
</div> <!-- End of pagination -->
</div>
Here is an image of my view:
15 records instead of 5
UPDATE:
I realize my mistake:
$data['query'] = $this->searchCases->getCases(); //I deleted this line, because i was getting all the results of the query.
and now in the view I replace $results instead $query in the foreach cycle and now I can see the 5 results per page that I'm asking for.
foreach ($query as $row) {?>
<tr>...
Changed to:
foreach ($results as $row) {?>
<tr>...
But now when I click on the link for the second page I have the same error 404 that I had from the start.
Try this $config['base_url'] = base_url().'index.php/opened_cases/index';
And change this $config['uri_segment'] = 3;
Related
I have a problem with pagination.when I click on the next but it brings the above error, but when I click on the previous link it works normally. here is my code for the controller:
public function categoryfour()
{
$config = array();
$config["base_url"] = base_url() . "bulletins/categoryfour";
$total_row = $this->news_model->record_count_category_four();
$config["total_rows"] = $total_row;
$config["per_page"] = 2;
$config["uri_segment"] = 3;
$config['use_page_numbers'] = TRUE;
$config['num_links'] = $total_row;
$config['cur_tag_open'] = ' <a class="current">';
$config['cur_tag_close'] = '</a>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["posts"] =$this->news_model->get_news_cat_four($config["per_page"], $page);
$str_links = $this->pagination->create_links();
$data["pages"] = explode(' ',$str_links );
$this->load->view('category_one',$data);
}
here is the code for the model:
function get_news_cat_four($limit, $start)
{
$this->db->select('news.id as newsId,news_category.id as catId,users.id as userId,news.*,news_category.*,users.*,comments.*, COUNT(comments.post_id) as num_comments');
$this->db->join('users' , 'users.id = news.user_id');
$this->db->join('news_category' , 'news_category.cat_id = news.news_id');
$this->db->join('comments' , 'comments.post_id = news.id');
$this->db->group_by('comments.post_id');
$this->db->order_by('news.date_added','desc');
$this->db->where('news.news_id',4);
$this->db->limit($limit, $start);
$query = $this->db->get("news");
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;}
and finally the view:
<div id="page-content" class="single-page container">
<div class="gutter-7px">
<div id="main-content" class="col-md-8 fix-right">
<article class="single-post">
<?php if(count($posts)) {
foreach($posts as $n){ ?>
<div class="entry-header">
<h1 class="entry-title"><?php echo $n->title;?></h1>
<span> <i class="fa fa-calendar"></i> <?php echo date( 'F jS, Y g:i a' , strtotime($n->date_added))?>/
<i class="fa fa-comment-o"></i>
<?php echo $n->num_comments;?>/<i class="fa fa-user"></i>
<?php echo $n->username?></span>
</div>
<div class="post-thumbnail-wrap"><a href="<?php echo base_url();?>bulletins/view/<?php echo $n->newsId?>"><img src="<?php echo base_url('assets/images/'.$n->image)?>"
style="width:800px;height:500px" /></a></div>
<div class="entry-content">
<p><?php echo substr(strip_tags($n->content), 0, 200).'...';?></p>
Read More...
<?php }}?>
</div>
</article>
<div id="pagination">
<ul class="pagination">
<!-- Show pagination links -->
<?php foreach ($pages as $link) {
echo "<li>". $link."</li>";
}
?>
</div>
</div>
</div>
I am trying to create a simple pagination in my CodeIgniter blog, here is my code, I am using auto loader for these
$autoload['libraries'] = array('database','session','pagination');
$autoload['helper'] = array('form','url');
My Controller;
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Blog extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('BlogModel');
}
public function index($offset=0)
{
$this->load->library('table');
$config["base_url"] = base_url('blog');
//$config["total_rows"] = $this->BlogModel->get_Count(); // There are currently 36 Posts
$config["total_rows"] = 36; // There are currently 36 Posts
$config["per_page"] = 5; // Change limit to suit what you would like
$config['use_page_numbers'] = TRUE;
$limit = $config['per_page'];
$this->pagination->initialize($config);
$blog_pagination = $this->pagination->create_links();
$Posts = $this->BlogModel->get_Posts($limit, $offset);
$assignData=array('data'=>$Posts,'blog_pagination'=>$blog_pagination);
$this->load->view('header');
$this->load->view('blog', $assignData);
$this->load->view('footer');
}
}
I Have this in my Model;
<?php
class BlogModel extends CI_Model {
public function __construct(){
// Call the Model constructor
parent::__construct();
$this->load->library('memcached_library');
}
public function get_Posts($limit, $offset){
$this->db->select('*');
$this->db->where('post_status','published');
$query= $this->db->get('cms_posts',$limit, $offset);
$data=$query->result_array();
return $data;
}
public function get_Count() {
//$query = $this->db->get($this->db->dbprefix . 'blog');
$this->db->select('*')->from('cms_posts');
$this->db->where('post_status','published');
$query= $this->db->get();
//$data=$query->result_array();
return $query->num_rows();
}
}
?>
I am using this in my View;
<div id="primary" class="left-column">
<?php
if(!empty($data)){
foreach($data as $row){
?>
<main id="main" role="main">
<article id="<?php echo $row['post_id']; ?>" class="post-item">
<div class="right">
<div class="post-thumbnail">
<img src="<?php echo base_url()."assets/images/uploads/test_n-150x150.jpg";?>" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" sizes="(max-width: 320px) 100vw, 320px" width="320" height="143">
</div>
<!-- END .post-thumbnail -->
</div>
<div class="left">
<h2 class="post-title">
<?php echo $row['post_title']; ?>
</h2>
<div class="post-meta">
<span class="vcard author">
<?php echo ucwords($row['post_author']); ?>
</span>
<time class="entry-date published" datetime="<?php echo $row['post_date']; ?>"><?php echo date("d M Y", strtotime($row['post_date'])); ?></time>
</div>
<div class="post-excerpt">
<p>
<?php
echo(substr($row['post_content'], 0, 250));
<a class="read-more" href="<?php echo base_url()."blog/".$row['post_url']; ?>">Read More »</a>
</p>
</div>
<!-- END .post-excerpt -->
</div>
<!-- END .left -->
</article>
<!-- END .post-item -->
</main>
<?php
}
}
?>
<!-- END .site-main -->
<div class="pagination-wrap">
<?php echo $blog_pagination; ?>
</div>
</div>
EDIT:
My Route is as under:
$route['default_controller'] = 'index';
$route['blog/:any'] = 'blog/post/$1';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
I don't know that what and where are I am missing something, please lead me or correct me in this code. thnk you
Update
My Blog show now 5 Post on First Page and create Pagination but on only 123>Last› pagination is created and there is page blank on offset 2 (/blog/2).
maybee you can use my methode use uri segment to $offset, like this
public function house()
{
$config['base_url'] = site_url().'/user/house/';
$config['total_rows'] = $this->houses->select_row_house_design();
$config['per_page'] = 12;
$config['cur_tag_open'] = '<li><a><b>';
$config['cur_tag_close'] = '</li></a></b>';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$this->pagination->initialize($config);
$from = $this->uri->segment('3');
$data['design'] = $this->houses->select_all_house_design($config['per_page'],$from);
$title['menu'] = 'house design';
$this->template('user/house',$data,$title);
}
set controller like this,
this is also simple
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Blog extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('BlogModel');
$this->load->library('table');
}
public function index($offset=0)
{
$config['base_url'] = site_url('blog/index');
$config["total_rows"] = $this->BlogModel->get_Count(); // There are currently 36 Posts
$config["per_page"] = 5; // Change limit to suit what you would like
$config['num_links'] = 10;
/*use this code for bootstrap
$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="active"><a class="">';
$config['cur_tag_close'] = '</a></li>';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '<li>';
$config['next_tag_open'] = '<li class="next">';
$config['next_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['first_link'] = '<<';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['last_link'] = '>>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
*/
$this->pagination->initialize($config);
$data['blog_pagination'] = $this->pagination->create_links();
$data['posts'] = $this->BlogModel->get_Posts($config['per_page'],$this->uri->segment(3));
$this->load->view('header');
$this->load->view('blog', $data);
$this->load->view('footer');
}
}
img
Every time I add a second comment, my post is duplicated. This appeared when I included comments in the system.
My code is below. Posts are duplicated every time I add a new comment.
1 comment = 1 post; 2 comments = 2 post; 3 comments = 3 post[...]
My Controller:
public function index()
{
if($this->session->userdata('u_logged') == TRUE)
{
$config = array();
$config['base_url'] = base_url().'core/index';
$config['total_rows'] = $this->core_model->types_count();
$config['per_page'] = 4;
$config['uri_segment'] = 3;
$config['use_page_numbers'] = TRUE;
$config['full_tag_open'] = "<ul class='pagination noborder'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled noborder'><li class='active noborder'><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>";
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['results'] = $this->core_model->fetchTypes($config['per_page'], $page);
$data['links'] = $this->pagination->create_links();
$data['notifications'] = $this->core_model->getLastNotifications();
$this->loadTemplate('pages', 'index_view', $data);
if(!empty($this->input->post('comm')))
{
$this->core_model->addComment();
}
}
else if($this->session->userdata('u_logged') == FALSE)
{
$this->loadTemplate('pages', 'index_view', '0');
}
}
My Model
public function types_count()
{
return $this->db->count_all('types');
}
public function fetchTypes($limit, $start)
{
$this->db->limit($limit, $start);
$this->db->order_by('t_id', 'DESC');
$this->db->from('types');
$this->db->join('comments', 'comments.c_type_id = types.t_id');
$query = $this->db->get();
if($query->num_rows() > 0)
{
foreach($query->result() as $row)
{
$data[] = $row;
}
return $data;
}
return false;
}
public function addComment()
{
$text = $this->input->post('inputComment');
$authorid = $this->session->userdata('u_id');
$typeid = $this->input->post('t_id');
$this->db->select('c_date');
$this->db->where('c_author', $authorid);
$query = $this->db->get('comments');
$data = $query->result();
if($query->num_rows() > 0)
{
if($data[0]->c_date - time() < -120)
{
$data = array(
'c_author' => $authorid,
'c_date' => time(),
'c_show' => '1',
'c_text' => $text,
'c_type_id' => $typeid
);
$this->db->insert('comments', $data);
}
else
{
echo 'poczekaj';
}
}
else
{
$data = array(
'c_author' => $authorid,
'c_date' => time(),
'c_show' => '1',
'c_text' => $text,
'c_type_id' => $typeid
);
$this->db->insert('comments', $data);
}
}
**And the view**
<?php foreach($results as $type) { ?>
<div class="panel panel-default noborder">
<div class="panel-body">
<div class="media noboder">
<div class="media-left">
<img class="media-object" style="width: 48px;" src="https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/13413743_1729080443973113_1289643015497858641_n.jpg?oh=98e497c14d65c2102bd9a41777447937&oe=582E9E1E">
</div>
<div class="media-body">
<h4 class="media-heading"><strong>Rafał Chojnowski</strong><small class="pull-right"><?php if($type->t_type_for == '0') { echo 'TYP DARMOWY'; } else { echo 'TYP PREMIUM'; } ?></small></h4>
<small><?php echo mdate($dateString, $type->t_date); ?></small><br />
<p>
<?php echo $type->t_match.', liga '.$type->t_league.', typ '.$type->t_type.', rozpocznie się '.$type->t_start_date.'. Kurs: '.$type->t_course.' '.$type->t_comment; ?>
</p>
</div>
<hr>
<?php foreach($results as $comment) { ?>
<div class="media-left">
<img class="media-object" style="width: 32px;" src="https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/13001028_1523205167987703_4311803603524761516_n.jpg?oh=fb2068c87060975ab7187cde7f1a161f&oe=57EA8DA5">
</div>
<div class="media-body">
<h6 class="media-heading"><strong>Tomasz Chwicewski</strong> <small><?php echo mdate($dateString, $comment->c_date); ?></small></h6>
<?php echo $comment->c_text; ?>
</div>
<br />
<?php } ?>
<?php $hidden = array('t_id' => $type->t_id, 'c_author' => $this->session->userdata('u_id'), 'comm' => '1'); ?>
<?php echo form_open('core/index', '', $hidden); ?>
<div class="input-group">
<input type="text" class="form-control input-sm noborder" name="inputComment" placeholder="Dodaj komentarz">
<span class="input-group-btn">
<button class="btn btn-primary btn-sm noborder" type="submit">Dodaj</button>
</span>
</div>
<?php echo form_close(); ?>
</div>
</div>
</div>
<?php } ?>
Good day,
Quick question,
I am using CI's pagination to my project,
it works perfectly, but i wanted to add some
filters on it.
i.e. I need to catch its click event.
although I can catch already its click event using this
$("ul.pagination > li a[href]").click(function(e){
loadingStart();
});
my problem is it still redirect to the next page,
what I need is something like this.
if(myVar == 0) {
//do not redirect
} else {
//redirect.
}
Use e.preventDefault(); and then execute your custom function
If you want filter for pagination that use $_GET ... no redirect in js (You can not undo, etc.).
I show you how I do:
Controller:
/**
Example list
**/
public function index()
{
$page = ($this->input->get('page') AND $this->input->get('page')>1)?(intval($this->input->get('page'))-1)*9:1; #9 item for page
#where if isset($_GET)
$where = array();
if($this->input->get('city')) {
$where['users.city'] = $this->input->get('city');
}
if($this->input->get('street')) {
$where['users.street'] = $this->input->get('street');
}
#load model
$this->load->model('users_m');
$view_data['users'] = $this->users_m->GetAll($where,$page,array('users.register_date'=>'DESC'))->result();
//pagination library
$this->load->library('pagination');
$config['base_url'] = site_url('/users');
$config['total_rows'] = $this->users_m->GetAll($where,0)->num_rows();
$config['per_page'] = 9;
$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['page_query_string'] = TRUE;
$config['query_string_segment'] = 'page';
$config['reuse_query_string'] = TRUE;
$config['use_page_numbers'] = true;
$config['last_tagl_close'] = "</li>";
$this->pagination->initialize($config);
//variable to template
$view_data['pagination'] = $this->pagination;
$this->load->view('/users/index',$view_data);
}
Model: users_m
/**
* Get all users example
**/
public function GetAll($where=array(),$page=1,$order_by=array(),$limit=9)
{
$this->db->select('users.*');
#order by
if(count($order_by)>0)
{
foreach($order_by as $key=>$value)
{
$this->db->order_by($key,$value);
}
}
$this->db->where($where);
#show all (for pagination calculate)
if($page==0) return $this->db->get_where('users',$where);
#show single page
return $this->db->get_where('users',$where,$limit,(($page==1)?$page-1:$page));
}
And view:
<div id="search_bar">
<?php echo form_open(site_url('/users'),array('class'=>'form-inline','method'=>'get'));?>
<div class="form-group col-lg-2 col-md-4 col-sm-4">
<select name="type" class="form-control">
<option value="" disabled="disabled" selected="selected" >City</option>
<option value="1" <?php if(set_value('city')==1) echo 'selected';?>>London</option>
<option value="2" <?php if(set_value('city')==2) echo 'selected';?>>Warsaw</option>
</select>
</div>
<button type="submit" class="btn btn-primary" style="margin-top:-10px;">Search</button>
<?php echo form_close();?>
</div>
<hr/>
<div id="grid-user" class="row">
<table>
<tbody>
<?php foreach($users as $user):?>
<tr>
<td><?php echo $user->id;?></td>
<td><?php echo $user->firstname;?></td>
<td><?php echo $user->lastname;?></td>
<td><?php echo date("d.m.Y",strtotime($user->register_date));?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
<div class="row">
<div class="col-lg-12">
<div style="float:right;"><?php echo $pagination->create_links();?></div>
</div>
</div>
I sorry for my english.
This is example (not checked, written from memory).
Try it :)
It so nightmare when using pagination on codeigniter. It work to move another page when click next or number after. But, the 'cur_tag_open' is not move. It still in first link of pagination. So let say, I clicked 3 on [1] [2] [3] , the class active still in one not in three. I can not find the solution of this problem, and this is my code :
CONTROLLER
class Control_direksi extends CI_Controller {
public function index() {
$this->show();
}
public function show() {
/** ======================================================= Inisialisasi table 1 =========================================================* */
$start_row = $this->uri->segment(4);
$per_page = 2;
if (trim($start_row) == '') {
$start_row = 0;
};
$total_rows = $this->model_request->hitungRequestMasukMD();
$this->load->library('pagination');
if ($total_rows != 0) {
$config['base_url'] = base_url() . 'direksi/control_direksi/show/';
$config['total_rows'] = $total_rows;
$config['per_page'] = $per_page;
$config['full_tag_open'] = '<div class="pagination pagination-centered" id="pagination1"><ul>';
$config['full_tag_close'] = '</ul></div><!--pagination-->';
$config['first_link'] = false;
$config['last_link'] = false;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = 'Prev';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = 'Next';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
}
$data['level'] = $this->session->userdata('level');
$data['pengguna'] = $this->model_user->get_username($this->session->userdata('username'));
$data['data_request_done'] = $this->model_request->get_data_request_belum_terkoreksi($per_page, $start_row);
$data['hitung_Request_Masuk_MD'] = $total_rows;
$this->load->view('direksi/view_direksi', $data);
}
VIEW
<body>
<!-- start: Header -->
<?php $this->load->view('/direksi/include/header.php') ?>
<!-- start: Header -->
<div class="container-fluid-full">
<div class="row-fluid">
<noscript>
<div class="alert alert-block span12">
<h4 class="alert-heading">Warning!</h4>
<p>You need to have JavaScript enabled to use this site.</p>
</div>
</noscript>
<!-- start: Content -->
<marquee>Jumlah Request Masuk ke MD: <?php echo $hitung_Request_Masuk_MD . ' request' ?></marquee>
<div class="box-header">
<h2><i class="halflings-icon align-justify"></i><span class="break"></span>Request masuk ke IT</h2>
<div class="box-icon">
<i class="halflings-icon chevron-up"></i>
</div>
</div>
<div class="box-content" id="things_table">
<?php $this->load->view('direksi/view_direksi_table'); ?>
</div>
</div>
</div>
<!-- end: Content -->
<?php $this->load->view('direksi/view_direksi_table_modal', TRUE); ?>
<div class="clearfix"></div>
<?php $this->load->view('/include/js.html', TRUE); ?>
</body>
Any help, it so appreciated
change 01
$start_row = $this->uri->segment(4);//remove this
and post after
$config['base_url'] = base_url() . 'direksi/control_direksi/show/';
$config['total_rows'] = $total_rows;
$config['per_page'] = 2;
$config['uri_segment'] = 3;//Uri_Segment
Change 02
$data['pagination'] = $this->pagination->create_links();
modify like this
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;//Add this line
$data['links'] = $this->pagination->create_links();
Change 03
in view.
where you want show your pagination list just use
<?php
echo $links;
?>
Important load this library in controller as well
$this->load->library('pagination');