|< 1 2 >| | 16 Einträge, 2 Seiten |
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
#!/usr/bin/perl
use warnings;
use strict;
use DBI;
use HTML::Template;
my $dbh;
my $such_standort = 'M';
my %row;
my @loop;
$dbh = DBI->connect ("DBI:mysql:host=192.168.42.6;database=cdmcrm",
"www-data", "www-data", {PrintError => 0, RaiseError => 1});
&mitarbeiter_suchen();
$dbh->disconnect();
exit(0);
sub mitarbeiter_suchen {
my $sth = $dbh->prepare ("
SELECT mitarbeiter.Nachname, mitarbeiter.Vorname, standorte.Standort, gesellschaften.Gesellschaft
FROM mitarbeiter
JOIN standorte, gesellschaften
WHERE mitarbeiter.Standort = standorte.SID
AND mitarbeiter.Gesellschaft = gesellschaften.GID
AND (standorte.Standort LIKE '$such_standort%')
");
$sth->execute();
while (my ($nachname, $vorname, $standort, $gesellschaft) = $sth->fetchrow_array()) {
%row = (
nachname => $nachname,
vorname => $vorname,
standort => $standort,
gesellschaft => $gesellschaft
);
push(@loop, \%row);
}
$sth->finish();
&html_ausgabe();
}
sub html_ausgabe {
my $template = HTML::Template->new(filename => 'staff.tmpl');
$template->param(staff_loop => \@loop);
print "Content-Type: text/html\n\n";
print $template->output;
}
QuoteGo on, admit it: You've written a templating system. It's OK, nearly everyone has at some point. You start with something beautifully simple like $HTML =~ s/\$(\w+)/${$1}/g and end up adding conditionals, loops and includes until you've created your own unmaintainable monster.
|< 1 2 >| | 16 Einträge, 2 Seiten |