How to set Pagination in order to redirect the page to the same url ?

Hi !

I'm newbie in the Frameworks world. I've looked through lot others as well but the performance of CI was the best. I've started to learn it through the tutorials, but I would like to develop it to get more know-how in CI.
So under this message I attached the code that response the first page and it's entries with the pagination script. But it isn't work well because there is some problem with the url and I don't know how i should modify to work properly ! So ... How should I modify the script to this action handle the
http://localhost/blog/ and the http://localhost/blog/index.php?test=test&page=2 url query as well.

Can someone help me ?

THX ! :-)

function index(){
$data['title']="CodeIgniter blog";
$data['heading']="My blog heading";
$config['base_url'] = 'http://localhost/blog/index.php?test=1';
$config['total_rows'] = $this->db->count_all('entries');
$config['per_page'] = '2';
if($this->uri->segment(2) == false ){
}else if($this->uri->segment(2) == true){
$data['pager'] = $this->pagination->create_links();


Why do you use Query String in your URL? It's much easier to do this:

function index()

function page($offset = 0)
        $limit = 2;
        // this should really be a model where you can give the offset and the limit
        $totalrows = $this->db->count_all(‘entries’);

        $config['base_url'] = site_url('nameofyourcontroller/page');
        $config['total_rows'] = $totalrows;
        $config['per_page'] = $limit;


Thanks your code was really helpful! Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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