gogoglou has asked for the wisdom of the Perl Monks concerning the following question:
#!/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 my $dbh = DBI->connect('DBI:mysql:mirnas', 'root', 'bi0u90ee') 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 where 1=0); #this works! +!! my $sth = $dbh->prepare("SELECT mirna FROM $table "); #this doesn't , it only displays the column name, not every row in the + column !!!!! $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">'; #here it submits the sel +ected parameters to a search form print br, '<INPUT TYPE = "SUBMIT"VALUE="Click To Submit">'; print '<INPUT TYPE="RESET"VALUE=Clear>'; print '</FORM>', end_html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl mysql and cgi 2
by moritz (Cardinal) on Mar 25, 2010 at 11:40 UTC |