hadoob024 Posted April 24, 2006 Share Posted April 24, 2006 I've read several tutorials and a ton of posts, and the code for implementing pagination seems to be pretty similar (the methodology at least). Anyway, I see how the code works, but I'm not sure how to apply it to my site in particular. I have a page "search.php", that has all the form information and creates sessions and passes this information as hidden tokens (to prevent against abuse of my forms). It passes the info to "searchresults.php". "searchresults.php" has the following structure:1) check SESSION variables (to prevent against CSR, session hijacking, and session fixation)2) initialize my variables which will store the info passed from the form3) check/screen info passed through POST and set my variables equal to these values4) validate information5) connect to db6) create and format results of SQL search string based on form information and by using SQL ORDER command7) query db8) if results found, display them, if not, then display generic message9) free resultset10) clean up SESSION, close tables, end scriptSo this layout works fine right now, but I want to add pagination and I guess my question is where/how to implement the pagination code given the layout of my "searchresults.php" page? Will all the SESSION stuff that I have mess this up? Will my form variables keep getting reset in between pages? Will the query be able to be passed ok? Quote Link to comment Share on other sites More sharing options...
waffle72 Posted April 24, 2006 Share Posted April 24, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]1) check SESSION variables (to prevent against CSR, session hijacking, and session fixation)2) initialize my variables which will store the info passed from the form3) check/screen info passed through POST and set my variables equal to these values4) validate information5) connect to db6) create and format results of SQL search string based on form information and by using SQL ORDER command7) query db8) if results found, display them, if not, then display generic message9) free resultset10) clean up SESSION, close tables, end script[/quote]Here are classes to install for pagination. It is pretty simple.[a href=\"http://www.ecreate.co.uk/diy/pagination.php\" target=\"_blank\"]http://www.ecreate.co.uk/diy/pagination.php[/a]To use this classes you will have to do somme change :5 bis) Do a query tha count the number of result you have with your parameter6) change your query to get just the number of results you want per pages ie : LIMIT $startRow, 209 bis) put link or a form that send to the next or previous pages.The actuel code use links to change pages so you have the parameters appearing in your URL but I suppose it is pretty easy to change it for buttons with a form and post method. So then you can send back all your session variables. Quote Link to comment Share on other sites More sharing options...
hadoob024 Posted April 25, 2006 Author Share Posted April 25, 2006 OK. I think I understand what you're saying. The only thing I'm not sure of is how to handle the links for previous/next pages. Can I get it to load a separate page instead? Right now, if I try to reload my "searchresults.php" page, I think my security/error handler won't allow for it. I guess I want to know if I can somehow use a separate page to handle the pagination instead of my main "searchresults.php" page? Quote Link to comment 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.