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

[eluser]maria clara[/eluser]
can you please try and analyze this in your CONTROLLER:
Code:
function index()
{
  $data['base'] = $this->config->item('base_url');
   $this->load->model('stock_model');
   $per_page = 10;
   $total = $this->stock_model->count_posts();  //total post
   $data['stocks'] = $this->stock_model->getStocks($per_page, $this->uri->segment(3));

   $this->load->library('pagination');
   $config['base_url'] = 'http://myapp/welcome/stocks/';
   $config['total_rows'] = $total;
   $config['per_page'] = $per_page;
   $config['uri_segment'] = '3';

   $this->pagination->initialize($config);
   $this->load->view('stocks_view', $data);
}

model:
Code:
function getStocks($limit = NULL, $offset = NULL)
{
  $this->db->limit($limit, $offset);
  return $this->db->get('stocks');
}

function count_posts()
{
  return $this->db->count_all_results('stocks');
}


Messages In This Thread
pagination help - by El Forum - 01-19-2010, 09:36 PM
pagination help - by El Forum - 01-19-2010, 09:55 PM
pagination help - by El Forum - 01-19-2010, 10:00 PM
pagination help - by El Forum - 01-19-2010, 10:37 PM
pagination help - by El Forum - 01-19-2010, 10:44 PM
pagination help - by El Forum - 01-19-2010, 11:15 PM
pagination help - by El Forum - 01-19-2010, 11:24 PM
pagination help - by El Forum - 01-19-2010, 11:35 PM
pagination help - by El Forum - 01-19-2010, 11:37 PM
pagination help - by El Forum - 01-20-2010, 12:08 AM
pagination help - by El Forum - 01-20-2010, 12:09 AM
pagination help - by El Forum - 01-20-2010, 12:22 AM
pagination help - by El Forum - 01-20-2010, 12:27 AM
pagination help - by El Forum - 01-20-2010, 12:28 AM
pagination help - by El Forum - 01-20-2010, 12:33 AM
pagination help - by El Forum - 01-20-2010, 12:58 AM
pagination help - by El Forum - 01-20-2010, 01:02 AM
pagination help - by El Forum - 01-20-2010, 01:09 AM
pagination help - by El Forum - 01-20-2010, 01:16 AM
pagination help - by El Forum - 01-20-2010, 03:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB