Hi there all,
I know that pagination has been covered a lot on the forum, and I know that arrays have been covered, multiple selections from lists/checkboxes, etc.
However, I cannot for the life of me figure out how to do this seemingly simple thing. On the upside, I am getting very good at pagination and syntax errors. :rolleyes:
I have a form that contains several inputs:
- checkboxes one (created w an array) - model type
- checkboxes two (created w an array) - colors
- textbox - year
- dropdown - date sold
The user should be able to select multiple checkboxes for each, as well as an 'all' option that will provide, well, all results for that criteria. (this 'all' part is getting less important, they can choose all of the boxes themselves :p )
The table is cars:
- model (vw, honda, etc)
- colors (blue, red, etc)
- year (1980 - 2000)
- date sold (05/07/2002)
The results should be listed according to the criteria selected, with 'prev/next' to step through x pages of results.
Here's the kicker - everything works great on the initial results display. But when you hit 'prev/next', the freakin thing looses the variable (array) from the initial form.
this is the select :
$result = mysql_query("SELECT * FROM cars WHERE model IN ('" . implode("','", $_POST['model']) . "') AND color IN ('" . implode("','", $_POST['color']) . "') AND year > 1980 ORDER BY price, model, year ASC LIMIT $off, $limit") or die(mysql_error());
I don't need anyone to re-write the code for me (unless you're looking for something to do? 😉 ), but I am at a loss as to what I can use here.
Should I be using sessions? What about the speed, having many users on at once? Should I have a different table structure? Is there another way to get the variable from form > page 1 > page 2 > other than through the url or with serialize?
I need someone to send me to the right snippit/site/post/book/search term so that I can get this done once and for all?
thanks folks