#!/usr/bin/perl -w
use strict;
use CGI qw(param);
use CGI::Carp qw(fatalsToBrowser set_message);
use DBI;
use Encode;
set_message('There is a problem in the script.
Send me a mail to (xy@z.net),
giving this error message and the time and date of the error.');
print "Content-type: text/html\n\n";
########################################################################
# program_name
########################################################################
my $script_name = $ENV{'SCRIPT_FILENAME'}; #get scriptname from cgi
if (defined($script_name) != 1) {
# for test local
$script_name = $0; # get scriptname
}
$script_name =~ s/^.+\///g;
########################################################################
# parameter
########################################################################
our $param_table = param('table'); # name of the table
$param_table = '' unless defined $param_table;
my $sql_statment = '';
my $title = 'Adressbuch';
if ($param_table eq '') {
$sql_statment = "SELECT table_name FROM information_schema.tables where table_schema='adressbuch';";
$title .= ' - Alle Tabellen';
} else {
$sql_statment = "SELECT * FROM ".$param_table.";";
$title .= ' - Tabelle '.$param_table;
}
########################################################################
# Begin HTML
########################################################################
###################################################################################
# HTML Head, Title
###################################################################################
print <
$title
HTML_HEAD
print "".$title."
";
my $dbh = DBI->connect( 'dbi:mysql:adressbuch',
'root',
'',
) || die "Database connection not made: $DBI::errstr";
my $sth = $dbh->prepare($sql_statment) or die ($dbh->errstr);
$sth->execute or die $sth->errstr;
print "";
while (my @array = $sth->fetchrow_array()) {
print "";
foreach (@array) {
if ($param_table eq '') {
print "\t".''.$_.''." | \n";
} else {
print "\t", $_, " | \n";
}
}
print "
\n";
}
print "
";
$dbh->disconnect();
print '';
print '';