#!C:\Program Files\Perl\bin\perl.exe -w package spyTech; do 'header.pl'; print start_html("Search"); print <

  Search

Sort By

Product ID
HTML print textfield(-name=>'id', -size=>10, value=>param('id')); print <
Name
HTML print textfield(-name=>'title', -size=>20, value=>param('title')); print <
Description
HTML print textfield(-name=>'description', -size=>40, value=>param('description')); print <
Manufacturer
HTML print textfield(-name=>'manufacturer', -size=>20, value=>param('manufacturer')); print <
Stock Quantity
HTML print textfield(-name=>'stock', -size=>10, value=>param('stock')); print <
Price
HTML print textfield(-name=>'price', -size=>10, value=>param('price')); print <



HTML if (param()) { my $query = "SELECT * FROM product WHERE true"; if (param('id') ne "") { $query .= " AND \"id\" = " . param('id'); } if (param('title') ne "") { $query .= " AND UPPER(\"title\") LIKE '%" . uc(param('title')) . "%'"; } if (param('description') ne "") { $query .= " AND UPPER(\"description\") LIKE '%" . uc(param('description')) . "%'"; } if (param('manufacturer') ne "") { $query .= " AND UPPER(\"manufacturer\") LIKE '%" . uc(param('manufacturer')) . "%'"; } if (param('stock') ne "") { $query .= " AND \"stock\" = " . param('stock'); } if (param('price') ne "") { $query .= " AND \"price\" = " . param('price'); } $query .= " ORDER BY " . param('orderby'); $dbh = DBI->connect("DBI:PgPP:dbname=$dbName;host=localhost", "$dbUser", "$dbPass") or die "Unable to connect to localhost because $DBI::errstr"; $sth = $dbh->prepare($query) or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute or die "Couldn't execute statement: " . $sth->errstr; print "",; print ""; my $i = 0; while (my @rows = $sth->fetchrow) { if ($i==0) { print ""; } else { print ""; } $i = ($i + 1) % 2; foreach my $field (@rows) { print ""; } print ""; } print "
$field
"; } print <
HTML print end_html();