Leser: 1
2 Einträge, 1 Seite |
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
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use CGI;
use FindBin;
use HTML::Template::Compiled;
my $query = CGI->new();
my %params = $query->Vars();
unless($params{action}){
$query->redirect("/formular.cgi");
}
else{
my $results = do_query(%params);
print $query->header();
my $template = HTML::Template::Compiled->new(
filename => $FindBin::Bin . '/results.tmpl',
);
$template->param(RESULTS => $results);
print $template->output();
}
sub do_query{
my (%params) = @_;
my $dbh = DBI->connect('DBI:mysql:tabelle:host','user','passwd') or die $DBI::errstr;
my $stmt = "SELECT * FROM tabelle WHERE Spalte1 = ? OR Spalte2 = ? OR Spalte3 = ? OR Spalte4 = ? OR Spalte5 = ? OR Spalte6 = ?";
my $sth = $dbh->prepare($stmt) or die $dbh->errstr;
$sth->execute( ($params{search}) x 6) or die $dbh->errstr;
my $results = $sth->fetchall_hashref();
return $results;
}
1
2
3
4
5
6
7
8
9
<html>
<body>
<form action="/cgi-bin/script.cgi" method="post">
<input type="hidden" name="action" value="1">
<input type="text" name="search">
<input type="submit">
</form>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
<html>
<body>
<table>
<TMPL_LOOP NAME=RESULTS>
<tr>
<td><TMPL_VAR NAME=Spalte1></td>
...
<td><TMPL_VAR NAME=Spalte20></td>
<td><a href="<TMPL_VAR NAME=ZUSAMMENGEBAUTERLINK ESCAPE=HTML>">Link</a></td>
</TMPL_LOOP>
</table>
</body>
</html>
2 Einträge, 1 Seite |