All pastes #283222 Raw Edit

Miscellany

public text v1 · immutable
#283222 ·published 2006-12-18 04:54 UTC
rendered paste body
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.");
}