Hello all,
I have a simple PHP page that queries a database and outputs the result set in an HTML table. It works fine. However, the result set is relatively large (2500ish records), so I want to apply a filter. Added an HTML form to the page that lets us filter the criteria. Again, works great. (Used GET method so that the URL could be linked).
Here's where my problem comes about. My boss wants the filters to be persistent, both within and between sessions. My first thought was cookies.. so I created a function called Filter() and call it at the top of my PHP document. It reads the cookie and applies the filters into the SQL statement. This works, but is rather kludgy. The problem I have is that when I first access the page, it doesn't seem to see the filters, it displays the full 2500ish record set. However, if I do a CTRL-R to reload the page, it then loads the filters correctly... it's almost like it renders the page before it can read the cookies in the initial pass.
Any thoughts on how to improve this, or am I taking a totally wrong approach?