Leser: 17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
use DBI; use HTML::Template; my $dbh = DBI->connect( "DBI:SQLite:sqlite_db" ); my $sth = $dbh->prepare( "SELECT name FROM sqlite_master ORDER BY name" ); $sth->execute(); my @tbls; while ( ( my $row ) = $sth->fetchrow_array ) { push @tbls, $row; } $dbh->disconnect; # table.html my $html = qq{ <html> <body> <form name="input" action="column.html" method="get"> # nächste Seite aufrufen <TMPL_LOOP TABLES> <input type="radio" name="table" value="<TMPL_VAR TABLE>" /> <TMPL_VAR TABLE><br /> </TMPL_LOOP> <br /> <input type="submit" value="Submit" /> </form> </body> </html> }; my $tmpl = HTML::Template->new( scalarref => \$html ); my @tables; for my $t ( @tbls ) { push @tables, { TABLE => $t } } $tmpl->param( TABLES => \@tables ); open my $fh, '>', 'tables.html' or die $!; $tmpl->output( print_to => $fh ); close $fh;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
use DBI; use HTML::Template; my $dbh = DBI->connect( "DBI:SQLite:sqlite_db" ); my $table = 'my_sqlite_table'; # vorher ausgewählter table my $sth = $dbh->prepare( "SELECT * FROM $table" ); $sth->execute(); my @col = @{$sth->{NAME}}; $dbh->disconnect; # column.html my $html = qq{<html> <body> <form name="input" action="where.html" method="get"> <TMPL_LOOP COLUMNS> <input type="checkbox" name="column" value="<TMPL_VAR COLUMN>" /> <TMPL_VAR COLUMN><br /> </TMPL_LOOP> <br /> <input type="submit" value="Submit" /> </form> </body> </html>}; my $tmpl = HTML::Template->new( scalarref => \$html ); my @columns; for my $c ( @col ) { push @columns, { COLUMN => $c } } $tmpl->param( COLUMNS => \@columns ); open my $fh, '>', 'columns.html' or die $!; $tmpl->output( print_to => $fh ); close $fh;
2011-03-20T10:49:34 KuerbisWenn ich mit dieser Seite die nächste mit HTML::Template erzeugte Seite aufrufen möchte - brauche ich dazu einen Webserver?