S
Sylvie Stone
Hi group - I have an html form where users can query the database
based on a bunch of criteria but I'm having trouble capturing all the
checked checkboxes to build the select statement. In php I would just
use implode.
I've been trying to use 'join' but to no avail.
The checkbox options are generated dynamically:
$dbh->prepare("select id,name from statuslookup where inactive is NULL
order by id");
$sth->execute();
my $ref_allrows = $sth->fetchall_arrayref;
my $i;
for $i (0 .. $#{$ref_allrows}) {
print "<input type=checkbox name=\"statuscodearray[]\"
value=\"$ref_allrows->[$i][0]\">$ref_allrows->[$i][0]
$ref_allrows->[$i][1]";
}
Then to process the form onsubmit:
<snip>
my @statuscodearray;
my $statuscode = join(" ", @statuscodearray);
<snip>
if (length($statuscode) > 0) {
$build_query = "$build_query and statuslink = '$statuscode'";
}
The array will hold integers like this:
select blah from blahblah where statuslink in ('1', '44', '55', '77')
..... ;
THANK YOU ! This is driving me crazy!
Sylvie.
based on a bunch of criteria but I'm having trouble capturing all the
checked checkboxes to build the select statement. In php I would just
use implode.
I've been trying to use 'join' but to no avail.
The checkbox options are generated dynamically:
$dbh->prepare("select id,name from statuslookup where inactive is NULL
order by id");
$sth->execute();
my $ref_allrows = $sth->fetchall_arrayref;
my $i;
for $i (0 .. $#{$ref_allrows}) {
print "<input type=checkbox name=\"statuscodearray[]\"
value=\"$ref_allrows->[$i][0]\">$ref_allrows->[$i][0]
$ref_allrows->[$i][1]";
}
Then to process the form onsubmit:
<snip>
my @statuscodearray;
my $statuscode = join(" ", @statuscodearray);
<snip>
if (length($statuscode) > 0) {
$build_query = "$build_query and statuslink = '$statuscode'";
}
The array will hold integers like this:
select blah from blahblah where statuslink in ('1', '44', '55', '77')
..... ;
THANK YOU ! This is driving me crazy!
Sylvie.