CodeIgniter Forums

Full Version: Help with the pagination class.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Twisted1919[/eluser]
Hi, i have a page where i list some products , and i use pagination. Nothing too complicated till here.
When using pagination ,beside the page numbers, i want to show something like :
on page 1: Listing 1-20 of 105 products
on page 2: Listing 20-40 of 100 products
[...]

[...]
Last page: Listing 100-105 of 105 products

I tryed but i can't achieve this, i know is not too complicated, but i miss something here ...
Thank you in advance !

El Forum

[eluser]Twisted1919[/eluser]
Heh, i found the answer by myself today in 5 minutes, it's amazing how being rest can think clearly Smile
here is the answer if somebody ever has this issue .
Code:
$segment = $this->uri->segment(3,0);
$num_results = 44 ;//number of results taken out from the database .
$perpage = 5 ;

$start = ($segment == 0 ) ? 1 : $segment ;
$end = (($segment+$perpage) < $num_results ) ? ($perpage + $segment) : $num_results ;
$data['showing'] = 'Listing '.$start.' - '.$end.'  of '.$num_results.' articles';

So, pretty simple ...