#!perl use strict; use CGI qw(:standard); use DBI; my $dbh = get_dbh(); # html page print header,start_html; my $sql = 'SELECT id,name,description,vers FROM software_repos'; my $sth = $dbh->prepare($sql); $sth->execute(); print q!!; while (my @f = $sth->fetchrow_array()){ print qq!\n!; } print q!
ID Name Description Version PDF
$f[0] $f[1] $f[2] $f[3] pdf
!; print end_html; # whatever you need to get a connection sub get_dbh{ my $database = ""; my $user = ""; my $pw = ""; my $dsn = "dbi:mysql:$database:localhost:3306"; my $dbh = DBI->connect($dsn, $user, $pw, { RaiseError => 1, AutoCommit => 1 } ); return $dbh; } #### #!perl use strict; use CGI qw(:standard); use DBI; my $id = param('id'); my $dbh = get_dbh(); my $sql = "SELECT bin FROM software_repos WHERE id=?"; my ($pdf) = $dbh->selectrow_array($sql,undef,$id); print header('application/pdf'), binmode(STDOUT); print $pdf; # whatever you need to get a connection sub get_dbh{}