• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination

#1
[eluser]praveena[/eluser]
HI
I am creating a pagiantion for my page I have a problem I was not able to create a link for second page
this is my code
CONTROLLER CODE
function index($row=0)
{
$this->load->model('page_model');
$this->load->library('pagination');
$config['base_url']='base_url()';
$config['total_rows']=$this->page_model->studentcount();
$config['per_page']='3';
$this->pagination->initialize($config);
$data['title']='Displaying Student List';
$data['list']=$this->page_model->getstudents();
$data['header']='Student List';
$data['links']=$this->pagination->create_links();
//$mem['list']=$this->page_model->getstudents();
$this->load->view('page_viewall',$data);
}
*********************************************************************************

Pls help me

#2
[eluser]InsiteFX[/eluser]
Code:
function index($row = 0)
{
    $this->load->model('page_model');
    $this->load->library('pagination');

    $config['base_url']    = 'http://yousite.com/index.php/function/page/';
    $config['total_rows']  = $this->page_model->studentcount();
    $config['per_page']    = '3';
    $config['uri_segment'] = 3;

    $this->pagination->initialize($config);

    $data['title']  = 'Displaying Student List';
    $data['list']   = $this->page_model->getstudents();
    $data['header'] = 'Student List';
    $data['links']  = $this->pagination->create_links();

    // $mem['list'] = $this->page_model->getstudents();
    $this->load->view('page_viewall', $data);
}

Read the CodeIgniter User Guide! Pagination Class

InsiteFX

#3
[eluser]Federico Baña[/eluser]
your "getstudents" method should have a parameter to indicate the page you're loading, like this:
Code:
$page = $this->uri->segment(3); // get the page from the query string (url)
$this->page_model->getstudents($page); // pass the page over to the model

and your query could be like:

Code:
public function getstudents($page)
{
    $this->db->limit($page, 3); // narrow your query to only the rows on the page
    $query = $this->db->get('students'); // run query
    return $query->result(); // return results
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.