Thanks everyone for the answer. I used the second reply and it worked. Now my code looks like this:
#!/usr/bin/perl
use DBI;
use CGI ':standard';
use strict; use warnings;
my $q= CGI->new();
print header, start_html('Advanced Search');
# Connect to the database
# See footnote 1
my $dbh = DBI->connect('DBI:mysql:mirnas', 'root', 'pass')
or die "Couldn't open database: $DBI::errstr; stopped";
# Getting all the column names and creating checkboxes for them
my $table = '07_11_09';
my $sth = $dbh->prepare("SELECT * FROM $table;");
$sth->execute;
my @cols = @{$sth->{NAME}}; # or NAME_lc if needed
$sth->finish;
#printing the checkboxes
print
checkbox_group(-name=>'fields_to_search',
-values=>\@cols # Your array above
);
#storing the parameters from the checkboxes
my @fields_to_search=param('fields_to_search');
#creating the submit boxes
print'<FORM
ACTION="http://sirocco/cgi-bin/advanced_search.pl"
METHOD="POST">';
print br, '<INPUT TYPE = "SUBMIT"VALUE="Click To Submit">';
print '<INPUT TYPE="RESET"VALUE=Clear>';
print '</FORM>', end_html;
But when I do that I don't get anything. Also how do I pass the @params to an sql statement Would it be something like my $sth = $dbh->prepare("SELECT * FROM $table WHERE tissue = @fields to search;"); THanks for any possibble answers in advance
|