How to get search key when someone edit the result after search How to get search key when someone edit the result after search codeigniter codeigniter

How to get search key when someone edit the result after search


What i would do personally is something like this on my list Page i would have a form which would be submitted to search function through GET method. This way i would have all my search Params in the URL and my URL would be something like this :

exampledomain.com/users?name=steve&age=23

Now for the edit page i would generate a link with a special parameter say : lastpage whose value would be some encoded form of the current search params. So when the user would go to the edit page the URL would be somthing like this:

exampledomain.com/users/edit/34?lastpage=erasc1235234safvdadsrgdfgbvcdfgrt435

when the edit functunality is completed. I would pick this lastpage Param form $_GET['lastpage'] ( or in CI you can use $this->input->get('lastpage')) to get the encoded value of lastpage and decode that to get all the previous URL search Params. and redirect the user to the serach function again with the search params attached to the URL.


I solved the same problem i had with dividing the view to two types

1) the normal view which shows all records and

2) the other view which shows all recently searched records for the last searched key.

To achieve this u need to store the searched records' ids and place from which the records have been taken to be stored in a temporary DB Table like TableforSearch and store the search key like 'ABC' in session.

On search of the Key 'ABC' find the ids of the records which matches the Key and save it to Table TableforSearch along with the Search Key and UserId.

Then use the Session to get the Key and search the table with the Key in Session to fetch the row that has All the Ids of the Searched Key.For Error Handling see if the Ids present in Table have not been deleted for that Record.

And finally on Showing of searched items Show the second Page , for the other show normal first page


In order to get the keyword that has been type. You have three options

  • Save keyword as GET variable
  • Save keyword as hidden input
  • Save keyword as SESSION variable
  • Save keyword as COOKIEvariable

Since that you don't to choose the option 3 and 4. Your only option is to create a GET variable.Just add domain.com/controller/function?keyword=ABCand get that on controller as rldecode($_GET['keyword']); or create hidden input where you can save you value and fetch that value.