Forum Moderators: coopster

Message Too Old, No Replies

Queries

Search within results

         

fashezee

4:40 pm on Aug 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When developing a "Search within results" feature in PHP; do you necessarily have to save
the initial results in the DB? or is there a function in PHP that would facilitate this
feature?

I would like to provide a "Search within results" feature on my site; however I am
a little worried about the overhead it may cause.

jpjones

5:12 pm on Aug 9, 2003 (gmt 0)

10+ Year Member



Have you thought about saving the last search term in a session variable, or in cookies, or even including the relevant variables in a hidden field in the form?
Then search within results could requery this data, with the addition of any extra search parameters.

You could also create a temporary table for the results, and drop it after a certain period of time (e.g. 1 hour).
You'd need some way to map to this table though - again perhaps a session/cookie/hidden field somewhere.

The second would probably create less overhead, but you'd have to put some housekeeping into your code.

JP

fashezee

5:47 pm on Aug 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My major concern is the overhead issue all the storing will cause. I will explore the
hidden fields and the session method.

Thanks.

martekbiz

9:40 pm on Aug 9, 2003 (gmt 0)

10+ Year Member



essentially what you're doing is caching a copy of the query and its results.

Where's the overhead?

If its a common query where the results don't change that often then you can do a query on the table to see if new data was added.

If not, switch out the query and simply enter the data set that is already stored otherwise allow the query to run as normal.

HTH

Aaron

lorax

1:42 am on Aug 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You could also store the results to a temporary table [mysql.com] and use that. It is destroyed once the connection is closed.