i made that change and i still cant get the links to correspond with the 3rd segment of uri
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
January 09, 2010 9:34pm
Subscribe [3]#16 / Jan 09, 2010 11:36pm
i made that change and i still cant get the links to correspond with the 3rd segment of uri
#17 / Jan 09, 2010 11:40pm
i changed it to like what you said and the uri is getting pull and querying the database correctly. right now im on the page ‘mysite.com/mains/index/5’ and its saying that im on page 2. Every link is in increments of 5 instead of one.
so my 2nd page link is mysite.com/mains/index/5
3rd page link is mysite.com/mains/index/10
4th page link is mysite.com/mains/index/15
#18 / Jan 09, 2010 11:49pm
oh alright so pagination is giving you an offset instead of a page number…in that case change
$offset = ($page-1) * $config['per_page'];to
$offset = $page;#19 / Jan 10, 2010 12:01am
same thing. page links are still in increments of 5
#20 / Jan 10, 2010 12:02am
The links will still be in increments of 5, but it should show the correct page now
0 = page 1
5 = page 2
10 = page 3
etc
#21 / Jan 10, 2010 12:05am
i think something is wrong with my $config. No clue what though
$this->load->library('pagination');
$config['base_url'] = 'http://mysite.com/mains/index/';
$config['total_rows'] = $this->db->count_all('test');
$config['per_page'] = '5';
$this->pagination->initialize($config);#22 / Jan 10, 2010 12:06am
OH…i thought the links would match with whats in the 3rd segment of the uri. then i guess its working now then
#23 / Jan 10, 2010 12:10am
THANK YOU SO FREAKIN MUCH
#24 / Jan 10, 2010 12:19am
question….if youre gonna use multiple functions in model, do you have to call it every time or can you just call it once?
#25 / Jan 10, 2010 9:27pm
hi,
i also encountered that one.. try this script.
$this->db->order_by($sidx,$sord);
$this->db->limit($limit, $start);
$query = $this->db->get('ar_so');
$count = $this->db->count_all_results();
// calculate the total pages for the query - code added by cess
if( $count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
// if for some reasons the requested page is greater than the total
// set the requested page to total page - code added by cess
if ($page > $total_pages) $page=$total_pages;
// calculate the starting position of the rows
$start = $limit * $page - $limit; // do not put $limit*($page - 1)
// if for some reasons start position is negative set it to 0
// typical case is that the user type 0 for the requested page
if($start <0) $start = 0;
$this->db->flush_cache();
$data['db'] = $query;
$data['page'] = $page;
$data['num'] = $total_pages;
$data['totalPages']=$count;
return $data;hope it would help you..
regards,
maria