In fact, there are lots of ways. You might want to consider a framework and an ORM layer to simplify your HTML and DB interaction. But here's a nice barebones solution in the vein of your original code.
See CGI for more information. ( http://search.cpan.org/~lds/CGI.pm-3.49/lib/CGI.pm )
#!/usr/bin/perl use DBI; use CGI; use strict; use warnings; my $q= CGI->new(); print $q->header(), $q->start_html(); # Connect to the database # See footnote 1 my $dbh = DBI->connect('DBI:mysql:mirnas', 'user', 'pass') or die "Couldn't open database: $DBI::errstr; stopped"; # Getting all the column names my $table = '07_11_09'; my $sth = $dbh->prepare("SELECT * FROM $table WHERE 1=0;"); $sth->execute; my @cols = @{$sth->{NAME}}; # or NAME_lc if needed $sth->finish; print $q->checkbox_group( -name=>'databases', -values=>[@cols], -linebreak=>'true', #-labels=>\%labels, #-attributes=>\%attributes ); print $q->end_html();
In reply to Re: perl, DBI and CGI checkboxes
by spazm
in thread perl, DBI and CGI checkboxes
by gogoglou
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |