Forum Moderators: open
A perl-y or PHP-like example is as follows, use the language of your choice:
## In this example, incoming values are stored in %qs
## If a box is not CHECKED, it will not be in the incoming vars
## so simply check for it's existence. @list is the
## array/list of the checkboxes.
@list = ('var1','var2','var3','var4');
foreach $var (@list) {
if ($qs{$var}) {
## you only need to "and" if $where has a value
if ($where) { $where .= ' and'; }
$where .= " field like '%$qs{$var}%'";
}
}
$select = "select * from table";
if ($where) { $select .= " where ($where);"; }
So if 1 and 3 are checked what you will have is
select * from table where (field like '%One%' and field like '%Three%');
Although it may be possible you are looking for OR, not AND. AND will only match on records meeting ALL conditions, or will match on ANY of the conditions.