sub view { my $table = shift(@_); my $dbh = DBI->connect(DSN, "", "") or die "Cannot connect to database: " . DBI->errstr; my $query = 'SELECT * FROM ' . $table . ';'; my $sth = $dbh->prepare($query) or die "Cannot prepare query: " . $dbh->errstr; $sth->execute() or die "Cannot execute query: " . $sth->errstr; my $rows = $sth->fetchall_arrayref(); $sth->finish(); my $tablerows = ""; foreach my $row (@$rows) { $tablerows .= Tr (td($row)); } print h1("$table contents"), br(), hr(), table($tablerows), br(), a({-href => "/cgi-bin/CBS.pl"}, "Back to the Main page."); }