Checkboxes & Pagination

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spartan7
Forum Commoner
Posts: 29
Joined: Sun Jun 19, 2005 12:09 am

Checkboxes & Pagination

Post by spartan7 »

Hi, I have hit a problem. I have a dynamically generated results page (from a search) where a user can select a number of options via checkboxes, which then pass on to the next page where they can email (based what they select on the checkboxes)...My problem is as follows, I have 25 results per page (It can go over 1000 in all for some searches) and each time I click "Next" to paginate the previous pages checkbox results are cleared. How do I maintain the checkbox values (and their checked status) from page to page during pagination so that all selections over all the pages can be passed onto the email form?

Thanks (Im a newbie don't hurt me)
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Pass the checkbox values from page to page via sessions.

Code: Select all

<input type="checkbox" name="checkbox" value="checkbox"<?php echo $_SESSION['checkbox']?' checked':''>
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Hmm, that code snippet doesn't feel right.

Code: Select all

Page 1 -> Page 2 -> Page 3 -- Submit -
  |         |         |              |
 \_/       \_/       \_/            \_/
Session Database -------------- > Email
No need to repopulate the checkboxes. ;-)
Post Reply