Schrift
[thread]254[/thread]

Template: HTML::Template



<< >> 2 Einträge, 1 Seite
tamtam
 2004-05-10 16:20
#2384 #2384
User since
2004-05-10
4 Artikel
BenutzerIn
[default_avatar]
Hi Leute

Mein Problem ist das ich eine Code ausgabe am Browser kriege, anstatt eine Formatierte HTML ausgabe.....Ein Einfaches Template funktioniert ohne Probleme.

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
!/usr/bin/perl -w

#load Modules
use strict;
use DBI ();
use HTML::Template;

#open the xhtml template
my $template = HTML::Template->new(filename => '../Documents/qms.version0.03/html.files/navigation.xhtml');

#################
##Database part##
#################
#Database Variable
my $dataSource = "dbi:mysql:qms";
my $user = "root";
my $passwd = "psalm5015";

#Database Connect
my $dbh = DBI->connect($dataSource, $user, $passwd,
{ "RaiseError" => 0, "AutoCommit" => 1, }
);
unless ($dbh) {
print("Fehler beim Verbindungsaufbau zur Datenbank (Code = $DBI::err)\n"
);
exit(1);
}

#Vorbereiten der SELECT-STATEMENTS
my $sql = "SELECT * FROM navi";
my $sth = $dbh->prepare($sql);
unless($sth) {
print("Konnte SQL-STATEMENTS nicht vorbereiten!\n");
}

#execute the SELECT-STATEMENTS
unless($sth->execute()) {
print("Fehler beim Ausf&uuml;ren von'$sql'-STATEMENT\n",
"Fehler = ' $sth->errstr() '\n"
);
exit(1);
}

#attributes
my $db_content;
my @navi_content = ();
my @navi_content4show = ();

#fill @array with database content
while(my @db_content = $sth->fetchrow_array()) {
foreach $db_content(@db_content) {
#set element on array for xhtml-link and xhtml show
push(@navi_content,$db_content);
push(@navi_content4show,ucfirst($db_content));
}
}

#################
##Template part##
#################
#initialize an array to hold yout loop
my @loop_data = ();

while(@navi_content and @navi_content4show) {
#get a fresh hash for the row data
my %row_data;

#fill in this row
$row_data{NAVI_CONTENT} = shift(@navi_content);
$row_data{NAVI_CONTENT_FOR_SHOW} = shift(@navi_content4show);

#the crucial step - push a reference to this row into the loop!
push(@loop_data, \%row_data);
}

#finally, assign the loop data to the loop param, again with a refernce.
$template->param(NAVI_LOOP => \@loop_data);

#print Header
print("Content-Type: text/plain\n\n");
print $template->output();

exit(0);

END {
if ($dbh) {
$dbh->disconnect();
}
}
tamtam
 2004-05-10 16:29
#2385 #2385
User since
2004-05-10
4 Artikel
BenutzerIn
[default_avatar]
Man bin ich blöd....:D

text/plain...jaja..:p
<< >> 2 Einträge, 1 Seite



View all threads created 2004-05-10 16:20.