#!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!
| ID |
Name |
Description |
Version |
PDF |
!;
while (my @f = $sth->fetchrow_array()){
print qq!
| $f[0] |
$f[1] |
$f[2] |
$f[3] |
pdf |
\n!;
}
print q!
!;
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;
}