How to hold the value of a POST between paging in Codeigniter?

Asked

Viewed 1,304 times

2

I have an element form with a select and a submit (filter). The data is filtered, the page is reloaded and the data is presented in a table. To see all the data, you pass through more than one page in the table (paging). However, I use a value that comes from the value of the last POST (content of select) and when I change pages in the table, the table shows the data of the first element of the select, because it does not retain the value of POST.

How can I save the post value so that pages after the first one are also shown?

2 answers

4

Instead of POST, you can pass the value of this <select> via GET and put it in your paging.

Example of link without filter:

pagina.php?p=3

Example of the link with the filter:

pagina.php?p=3&filtro=teste

Post some code so we can help you better.

  • Actually, it seems to make more sense to use GET.

  • @Diegosouza I say from experience. Filters in get can be ugly, but via post they are worse from the point of view of the user, who cannot bookmark a url with his preferred filters for example.

1

A good way is to use Session, type when filling the form and send stores the post data in sassion, and your filter goes on to retrieve the information from Session.

so you can transfer your post data from one page to another.

  • For this type of operation (searches and, mainly, with pagination), it is always good to use the method GET even, because the same is the most appropriate for that.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.