fizix Posted October 26, 2009 Share Posted October 26, 2009 Ok, I thought this would be an easy one at first but it's turned in to something more complicated than I expected: I have a database that can be searched and I allow my users to save their searches. I want to allow them to view all the new results since they last ran the search. That part is easy... I just save the timestamp for the last time they ran the search to a 'lastrun' column is SQL and update 'lastrun' every time the search is run. However, I run in to problems with multi-page results... When they move to the next page it thinks that the search was run a few minutes or seconds ago so page 2 is blank. My question is: how can I tell when the user is done with his/her search so that I can update the 'lastrun' parameter? Quote Link to comment Share on other sites More sharing options...
akitchin Posted October 26, 2009 Share Posted October 26, 2009 one option would be to set a session variable (assuming you're okay with using sessions) that contains the total number of results (or pages). then when you go to run the procedure for storing the lastrun value, you can check the current page/limit against the stored maximum and decide from there. if you decide to update it, don't forget to clear the session variable so that future "new results only" queries experience no interference. Quote Link to comment Share on other sites More sharing options...
fizix Posted October 27, 2009 Author Share Posted October 27, 2009 one option would be to set a session variable (assuming you're okay with using sessions) that contains the total number of results (or pages). then when you go to run the procedure for storing the lastrun value, you can check the current page/limit against the stored maximum and decide from there. if you decide to update it, don't forget to clear the session variable so that future "new results only" queries experience no interference. That's a good idea. I think I'll do something similar such as storing a session variable with the ID of the search that they're currently looking at. Then if they view a different search I'll just reset that variable (and of course it will be reset when they log out). 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.