#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use DBI;
use strict;

print header;
print start_html("Kite Catalog");

my $dbh = DBI->connect( "dbi:mysql:products", "webserver", "", { RaiseError =>
 1, AutoCommit => 1 }) or &dienice("Can't connect to database: $DBI::errstr");

print h2("Kite Catalog");

my $sth = $dbh->prepare(qq(select stocknum,name,price from items where status != "OUT" order by stocknum)) or &dienice("Can't select from table: ",$dbh->errmsg);


while (my($stocknum,$name,$price) = $sth->fetchrow_array) {
   print qq(<b>$name</b> - \$$price<br>\n);
   print qq(<a href="addcart.cgi?$stocknum">Add to Cart</a><br><br>\n);

print end_html;

sub dienice {
    my($msg) = @_;
    print "<h2>Error</h2>\n";
    print $msg;