PHP function to save me tons of work/code

Wow, I just happened to be looking around through the PHP manual and I found some really useful code in the classes section. For awhile now, I've been trying to figure out how to get my image search form working. I wanted to be able to split the results over more than 1 page (for users with low bandwidth) but was trying to figure out how to carry over the results to the next page (without having to do the query again). The page on classes has a tip for how to make a class carry over to another page which is exactly what I want to do. This is also really handy for other parts of my site as well. For instance, if you click on an individual image from the search results, I want to have links to the previous and next result (as well as back up to the results page). Right now, I was doing this in a horribly kludgy way that involved additional database hits. With this new technique, I should be to just do 1 database query and then carry those results over to various pages without doing any additional database queries. Also, I may be able to use this to achieve the abstraction that I mentioned wanting, that would require a bit more playing to determine if it's possible or not. Still, I'm really happy that I can get the carry over working because that's been the big thing holding me back in finishing off my image search interface.