phpnewbie34 Posted May 6, 2013 Share Posted May 6, 2013 My php page is Pagination style with a few pages Is a possible to add a search bar to pagination website? How do I carry the search term over in the address bar w/ pagination? Quote Link to comment https://forums.phpfreaks.com/topic/277725-how-to-add-search-tool-to-a-pagination-php-script/ Share on other sites More sharing options...
RonnieCosta50 Posted May 6, 2013 Share Posted May 6, 2013 Please provide more details. I'm confused about what you want to accomplish. Quote Link to comment https://forums.phpfreaks.com/topic/277725-how-to-add-search-tool-to-a-pagination-php-script/#findComment-1428711 Share on other sites More sharing options...
Psycho Posted May 6, 2013 Share Posted May 6, 2013 How do I carry the search term over in the address bar w/ pagination? It can be done many different ways. How you do it depends on how you want it to work. 1. Normally on your pagination navigation links you will add a parameter to identify which page to show (e.g. showdata.php?page=3). You could add an additional parameter to also pass the search term. If you only have a single search field this isn't a terrible solution. But, if you add more fields, it definitely makes the URL ugly. 2. You could store the search value in a cookie. Then on each load of the pagination script check to see if there is a value in the cookie for the search string. If you want the search string to persist between sessions (perhaps the user has a preferred view) this makes sense. For pagination, I only store things in cookies such as 'preferences' such as the number of records per page. 3. Session data. This would be my preferred approach. But, no matter where you store it, the logic would work something like this: 1. Check if new search values have been sent (i.e. POST data). If so, use that data for the query and save it to wherever you are storing it. 2. If no new search data was passed, check if there is existing search criteria where you store it (Cookie, Session, GET, etc.). IF so, use it 3. If no new data was passed and no data exists in the saved location, then assume there is no search criteria. Quote Link to comment https://forums.phpfreaks.com/topic/277725-how-to-add-search-tool-to-a-pagination-php-script/#findComment-1428714 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.