php - Codeigniter pagination not showing content on page 2 -


i searching 2 days still no luck. problem codeigniter pagination have set controller show 1 data per page have 2 data means have 1,2 pagination. [1] page showing correct data, when try click [2] still shows data [1] page plus url page=1.

here controller

class campaign extends ci_controller  {  public function __construct() {  parent::__construct();  $this->load->helper(array('form', 'url'));  $this->load->library('form_validation');  $this->load->model('campaign_model');  $this->load->database();  $this->load->library('pagination');  }    function index() {  $this->load->view('campaign_view');  }    function submit() {  $this->form_validation->set_rules('campaignname', 'campaign name', 'trim|required|is_unique[ch_campaigns.c_campaign_name]');    if($this->form_validation->run() == false) {  echo validation_errors();  } else {  $campaignname = $this->input->post('campaignname');    $data = array (  'c_campaign_name' => $campaignname  );    $this->db->insert('ch_campaigns', $data);    echo "yes";  }  }    public function campaigns() {    $data = array();    //pagination settings  $config['base_url'] = site_url('campaigns');  $config['total_rows'] = $this->db->count_all('ch_campaigns');  $config['per_page'] = "1";  $config["uri_segment"] = 3;  $choice = $config["total_rows"] / $config["per_page"];  $config["num_links"] = floor($choice);    //config bootstrap pagination class integration  $config['full_tag_open'] = '<ul class="pagination">';  $config['full_tag_close'] = '</ul>';  $config['first_link'] = false;  $config['last_link'] = false;  $config['first_tag_open'] = '<li>';  $config['first_tag_close'] = '</li>';  $config['prev_link'] = '&laquo';  $config['prev_tag_open'] = '<li class="prev">';  $config['prev_tag_close'] = '</li>';  $config['next_link'] = '&raquo';  $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['page'] = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;    //call model function department data  $data['campaignlist'] = $this->campaign_model->get_campaign_list($config["per_page"], $data['page']);             //$data['campaigninfo'] = $this->campaign_model->get_campaign_list();  $data['pagination'] = $this->pagination->create_links();    //load department_view  //print var_export($data, true);  $this->load->view('campaign_view',$data);  }  }

here model

public function __construct() {  parent::__construct();  }    public function get_campaign_list($limit, $start) {  $this->db->select('*');  $this->db->from('ch_campaigns');  $this->db->limit($limit, $start);    $query = $this->db->get();    if($query->num_rows() > 0 ) {  foreach ($query->result() $row) {  $data[] = $row;  }    return $data;  }    return false;  }  }

lastly views

<table class="table table-striped table-hover">  <thead>  <tr>  <th>campaign name</th>  <th>owner</th>  <th>status</th>  <th>start date</th>  <th>end date</th>  <th>total leads</th>  <th> </th>  </tr>  </thead>  <tbody>  <?php foreach($campaignlist $list) { ?>  <tr>  <td><?php echo $list->c_campaign_name; ?></td>  <td><?php echo $list->c_customer_name; ?></td>  <td><?php echo $list->c_status; ?></td>  <td><?php echo $list->c_start_date; ?></td>  <td><?php echo $list->c_end_date; ?></td>  <td></td>  <td><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="fa fa-caret-square-o-down"></span></a>  <ul class="dropdown-menu">  <li><a href="#">edit</a></li>  <li><a href="#">delete</a></li>  </ul>  </td>  </tr>  <?php } ?>  </tbody>  </table>  </div>  <div class="main-container-footer text-center">  <?php echo $pagination; ?>  </div>


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -