Jump to content

How to only show results since the last time a query was run


fizix

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.