From: "Benjamin Jeeves" <[EMAIL PROTECTED]>
> I have a form with a number of checkboxs on it and
> what I would like to be able to do is build a query
> base on the checked checkedboxes.
All depends on what you're actually doing, but I assume each checkbox is
related to a row in the database? And each row as a unique identifier (like
an auto_increment number)?
If you name you checkboxes such as "box[]" and put the unique identifier as
the value, it's easy to build a list of checkboxes that were checked.
<input type="checkbox" name="box[]" value="1">
<input type="checkbox" name="box[]" value="2">
<input type="checkbox" name="box[]" value="3">
You can now build a query such as:
<?php
if(isset($_POST['box']) AND is_array($_POST['box']) &&
!empty($_POST['box']))
{ $query = 'SELECT * FROM table WHERE id IN (' . implode(',',$_POST['box'])
. ')'; }
You may want to actually loop through $_POST['box'], though, and validate
each value as a number, string, etc, before you stick then in your query.
---John Holmes...
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php