Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: perl, DBI and CGI checkboxes

by spazm (Monk)
on Mar 22, 2010 at 15:53 UTC ( #830106=note: print w/replies, xml ) Need Help??

in reply to perl, DBI and CGI checkboxes


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. ( )

#!/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();

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://830106]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2016-10-23 01:37 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (299 votes). Check out past polls.