Thread HTML::Template TMPL_IF Block in TMPL_LOOP Block (9 answers)
Opened by kruemmel at 2007-01-14 17:28

kruemmel
 2007-01-14 17:49
#73199 #73199
User since
2006-02-12
33 Artikel
BenutzerIn
[default_avatar]
hier mal mein Code


Code: (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
35
36
37
38
39
40
41
42
#!/usr/bin/perl -w

use strict;
#use CGI;
use DBI;
use HTML::Template;


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Datenbankdaten und Verbindung zur DB herstellen
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Datenbank
my $datenbank = "info";
# Datenbankhost
my $datenbankhost = "127.0.0.1";
# Datenbankusername
my $datenbankuser = "root";
# Datenbankpasswort
my $datenbankpw = "";


my $dbh = DBI->connect("DBI:mysql:$datenbank:$datenbankhost","$datenbankuser","$datenbankpw")
or die "Fehler bei der Datenbankverbindung aufgetreten.";

#my $CGI = CGI->new();

my $sth = $dbh->prepare('select Monat, Tag, Zeit, Host, Dienst, Meldung
from infotable');

$sth->execute();

my $rows;
push @{$rows}, $_ while $_ = $sth->fetchrow_hashref();

my $template = HTML::Template->new(filename => 'template1.html');
$template->param(data => $rows);

#print $CGI->header();
print "Content-Type: text/html\n\n";
print $template->output();

$dbh->disconnect();

View full thread HTML::Template TMPL_IF Block in TMPL_LOOP Block