Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-06-26 17:33 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (583 votes). Check out past polls.