[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
?>
here is my model "customer_model"
Code:
<?php
class Customer_Model extends CI_model{
function get_data($num,$offset)
{
$query = $this->db->get('dimcustomer', $num, $offset);
return $query;
}//end of function
?>
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">
<html >
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href='<?php echo base_url(); ?>css/main.css' type="text/css" media="screen, projection" />
<title>CodeIgniter Pagination Tutorial</title>
</head>
<body>
<h1>Christian Books</h1>
<?php echo $this->table->generate($results); ?>
<?php echo $this->pagination->create_links(); ?>
</body>
</html>
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