CodeIgniter Forums

Full Version: Pagination URI conflict
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Apologies if this is an easy one...

I have a view that has the following URL


With pagination when each page is called it appends the URL as expected



but also on this page I have a call to a function inside the controller, appended with the ID of a record I want to delete, so the call will look something like the following:


the problem is the this clashes with the pagination and after a delete the form jumps to an offset of 86, then say 20 that the page was origanlly on.

Thought I might turn on page query string, but had problems with & in the query string result and also read that its not really the codeigniter way. So went back to URI segments.

Thought that maybe I could use

$paginator_config['uri_segment'] = 4;

but that did not work, my thoughts where that when the page first loads the URL is site/databaselist so a third URI does not exist at that point, and visa versa for the elete call - this is kinda the part that is making this a little confusing for me.

Thanks for your help in advance.

El Forum

For anyone thats interested this is how I fixed it:

The call to the controller databaselist function I added the following

function databaselist($offset = 0)
{$data['offset'] = $offset;}

and within my call to delete or edit a record I added $offset to the string so that it always formatted correctly:

<?php echo anchor(site_url().'/site/delete/'.$offset.'/'.$rows->id_person, 'Delete', $attr, $img_delete);?>

Its probably not the best way to delete a record as anyone could put the URL in and delete it anything, but work on that later :-)