Hello Brian, Storing the result set in session or cookie is not a good idea. You can implement some caching mechanism in your search results. I implemented this in my project and it works simply great. Its very simple, You have to write two functions 1- writeCache($id, $data, $ttl) This routine will write data (serialized result set) in cache (file system) with ttl (time to live as timestamp). $id is the file name on disk. you can use md5 of your sql query. Example: $query = "select * from table limit 0, 100" $id = md5($query); $data = serialize(resultSet) $ttl = time()+ 600; ////10 minutes When you executes your page first time, the above routine will generate a cache file on disk (data from SQL) When you execute your page 2nd time the getCache() will check the validity of cache, if its valid then displays data from cache and if invalid creates the new cache for next 10 minutes 2- getCache($id) This function will checks the validity of cache and return false or unserialized record set from cache This mechanism will save your lot of MySQL queries in searching becoz you are not querying every time. If your data is static you can increase the $ttl accordingly. -- Shafiq Rehman Sr. Web Engineer http://www.phpgurru.com On 7/13/06, Brian Anderson <brian@xxxxxxxxxxxxxxxx> wrote:
Hello, I have a question about how I am searching through a products database. What I am wanting to do is store the result set so that I can provide a link to go back to previous searches quickly, and also manipulate it quickly. If I had a flat catalog of pages I could index the content in a few tables and go with that, but I want the results to be customizable, and more flexible than ten links to ten items on ten different pages. I want the results delivered and recombined in one page. Currently what I am doing is the following: 1. I open an SQL statement with delimiters 2. I circulate through the entries and append to a array called $pageset both the item number and a ranking based on keywords etc. 3. I sort the array by relevance ranking 4. I figure out what my limit and offset are in my array and paginate based on user input. 5. I grab the 20 or so array elements within the range and create a new array called $display set. 6. For each of the current page items I pull the full item details from the database and propagate the array to my html template I wonder if instead of propagating the $pageset (results index) array every time I could store the $pageset array as a cookie or session variable. It is a small array with a few hundred elements and rankings, but if I could store it, I wouldn't have to build the array and do a relevancy sort every time I paginate to the next page. I would just take the current stored search array which is already sorted, and grab element x through element y. Would this be an efficient way using a session variable? Does anybody else handle search results in a similar way? -Brian Anderson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php