Welcome Guest, Not a member yet? Register   Sign In
Search results saved to a session for pagination
#3

[eluser]pickupman[/eluser]
Looks like you are pretty close. I few recommendations that I have found when doing something similar. Don't be afraid to put the logic into different methods. I found myself early on trying to lump several page functions all into one massive method. Even putting them into private methods and calling them from the index() method can clean things up a bit. This may seem weird now, but when you come back to code you wrote a year ago, you will wonder what all the if() statements are.

1. Change base_url to:
Code:
//Pagination
$config['base_url'] = site_url("items/index"); // Make life easier on yourself in the future

2. You need to save the search term in your session. That way when you click a paginated link, and go to the next page, the code will skip that code block. You need to check if the search term exists in session or the posted value. With your code logic, this is why the search should be its own method. You can't determine if the user is still searching or viewing all rows.


Messages In This Thread
Search results saved to a session for pagination - by El Forum - 07-25-2012, 11:16 AM
Search results saved to a session for pagination - by El Forum - 07-26-2012, 05:05 AM
Search results saved to a session for pagination - by El Forum - 07-26-2012, 10:01 AM
Search results saved to a session for pagination - by El Forum - 08-29-2012, 11:17 PM
Search results saved to a session for pagination - by El Forum - 08-30-2012, 06:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB