use CGI; my $q = CGI->new; my %params = $q->Vars; my %links = ("red" => "redscript", "black" => "blackscript"); my $dbh = DBI->connect("DBD:$database:$sid","$user","$pass") or die "$0 connect " . DBI->errstr; my $sql = "select detail1, detail2 detail3 from detail_table where id = ?"; my $sth = $dbh->prepare($sql) or die "$0 prepare $sql " . $dbh->errstr; $sth->execute($params{id}) or die "$0 execute $params{id} " . $dbh->errstr; print $q->header,$q->start_html,$q->start_table; while (my @row = $sth->fetchrow_array()) { print $q->Tr($q->td([$row[0], $row[1], $q->a({-href=>"/cgi-bin/$links[$row[0]].pl?id=$params{id}"}, "link to $row[0]") ])); } print $q->end_table,$q->end_html;