Okay, looking for something pretty straightforward, but I want to approach it in a logical direction.

I want a simple output table that will display the columns returned by the query, with each header being clickable to resort the table by that header. I would also like pagination, preferably with variable items per page.

So I know the basics of doing the pagination, and am already doing it on other pages. I can figure out how to dynamically adjust the search query to handle the resorting via the headers. I can do it all piece by piece, and could pretty easily do it all for any given search query.

The issue here is I would love to abstract this so that I can just pass some information to a page/function and have it generate what I need for different queries.

What is the best suggestions for how do do this? Make single page for all of them that calls a function to return the page content?

I am running into an issue with having so many variables here:
base sql statement
sort field
lines per page
header names
mysql fieldnames associated with each header
page title information

How do I get all those variable passed to the display page? I can't post without a form, can I? I can't trust that sessions will be available as the user may have cookies turned off (I am using cookie only sessions elsewhere on the site). I sure don't want to stick a search query in full into the url...

Any suggestions? Am I barking up the wrong tree here?