Thread Brauche ich zum Datenaustausch zwischen HTML-Seiten einen Webserver? (3 answers)
Opened by Kuerbis at 2011-03-20 11:49

Kuerbis
 2011-03-20 11:49
#146671 #146671
User since
2011-03-20
943 Artikel
BenutzerIn
[default_avatar]
Code: (dl )
1
2
3
4
5
6
7
<html>
<body>
<p>
<a href="table.html">Table-Auswahl</a>
</p>
</body>
</html>

Wenn ich mit dieser Seite die nächste mit HTML::Template erzeugte Seite aufrufen möchte - brauche ich dazu einen Webserver?

Code (perl): (dl )
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;


Code (perl): (dl )
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;

Last edited: 2011-03-20 12:41:12 +0100 (CET)

View full thread Brauche ich zum Datenaustausch zwischen HTML-Seiten einen Webserver?