RE: multiple checkbox selection for search form

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I need some assistance here...
> I am toying with a search form that will allow the user to select 3
> options from a set of checkboxes to search by (eg.)
> 
> [[ Select any 3 type ]]
> 
> [ ] option1   [ ] option2   [ ] option3
> [ ] option4   [ ] option5   [ ] option6
> [ ] option7   [ ] option8   [ ] option9
> 
> what I would like to do is to allow then to select only 3 options
> then search the database for the 3 options selected.

Name all of your checkboxes the same, with an [] on it. 

<input type="checkbox" name="option[]" value="option1"> Option1
<input type="checkbox" name="option[]" value="option2"> Option2
etc...

Then, you'll have a $_POST['option'] array (or $_GET) when your form is
submitted. 

if(isset($_POST['option']) && count($_POST['option']) <= 3)
{ //perform your search }
else
{ echo "You must select between 1 and 3 options."; }

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux