Welcome Guest, Not a member yet? Register   Sign In
pagination
#1

[eluser]mehwish[/eluser]
hello everyone ... i am using the pagination class and almost written the code for it but facing some problem in retrieving the next records from databse when i click next pagination link.

this is my controller "customer_controller"
Code:
<?php

class Customer_Controller extends CI_Controller{


function index()
{

    $this->load->library('pagination');
    $config['base_url'] = base_url().'index.php/task2/index/';
    $config['total_rows'] = $this->db->count_all('dimcustomer');
    $config['per_page'] = '5';
    //$config['num_links'] = '3';
    //$config['page_query_string'] = TRUE;
    $config['full_tag_open'] = '<p>';
    $config['full_tag_close'] = '</p>';
    $offset=$offset+5;
    $this->pagination->initialize($config);

    $this->load->model('customer_model');
    $data['results'] = $this->customer_model->get_data($config['per_page'],$offset);


// load the HTML Table Class
    $this->load->library('table');
    $this->table->set_heading('ID', 'Title', 'Author', 'Description');

    // load the view
    $this->load->view('viewcustomer_view', $data);


}//end of function
?&gt;



here is my model "customer_model"

Code:
&lt;?php

class Customer_Model extends CI_model{


function get_data($num,$offset)
    {
        $query = $this->db->get('dimcustomer', $num, $offset);
    return $query;
}//end of function
?&gt;


and here is the view "viewcustomer_view"
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
&lt;link rel="stylesheet" href='&lt;?php echo base_url(); ?&gt;css/main.css' type="text/css" media="screen, projection" /&gt;
&lt;title&gt;CodeIgniter Pagination Tutorial&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<h1>Christian Books</h1>
&lt;?php echo $this->table->generate($results); ?&gt;
&lt;?php echo $this->pagination->create_links(); ?&gt;
&lt;/body&gt;
&lt;/html&gt;


actually i have copy the code from godbit project to understand but when i click digit 2 to show the some next records it shows something like a website task2.com/index/5 here task2 is my project name. please solve this out
#2

[eluser]adityamenon[/eluser]
You forgot to provide $config['uri_segment'] in your controller. CodeIgniter doesn't know where to find the number which indicates which page it's on otherwise.




Theme © iAndrew 2016 - Forum software by © MyBB