#!/usr/bin/perl require 'session.cgi'; my %form = map { $_ => join "\0",$cgi->param($_) } $cgi->param(); if($form{'value'}){ $sets = &GetManSets($form{'value'}); }else{ $sets = &GetSet($form{'setID'}); } &ShowDetail($sets); ##---------sub routines----------------------------- sub GetManSets{ my($id) = shift; my($statement, $sth, $rv, $set); $statement = "SELECT * FROM product_set,set_link,dept_relations WHERE dept_relations.deptid='$id' AND dept_relations.setid=product_set.id AND product_set.available<>'3' AND product_set.id=set_link.setid AND set_link.siteid='1' ORDER BY product_set.setname"; $sth = $dbh->prepare($statement) || die "Can't prepare $statement: $dbh->errstr\n"; $rv = $sth->execute || die "Can't execute the query: $sth->errstr\n"; return $sth; } # ----------------------------- sub GetSet{ my($id) = shift; my($statement, $sth, $rv, $set); $statement = "SELECT * FROM product_set,set_link WHERE product_set.id='$id' AND product_set.available<>'3' AND product_set.id=set_link.setid AND set_link.siteid='1' ORDER BY product_set.setname"; $sth = $dbh->prepare($statement) || die "Can't prepare $statement: $dbh->errstr\n"; $rv = $sth->execute || die "Can't execute the query: $sth->errstr\n"; return $sth; } # ----------------------------- sub GetBrandName{ my $id = shift; my($statement, $sth, $rv); $statement = "SELECT top_manufacture.name FROM top_manufacture,dept_link,dept_relations WHERE dept_relations.setid='$id' AND dept_relations.deptid=dept_link.deptid AND dept_link.top_manid=top_manufacture.id"; $sth = $dbh->prepare($statement) || die "Can't prepare statement: $!\n"; $rv = $sth->execute || die "Can't execute statement: $!\n"; @names = $sth->fetchrow_array; return @names; } # ----------------------------- sub ShowDetail{ my($sth) = shift; my($header) = "header.inc"; my($footer) = "footer.inc"; my $something = 0; &IncludeFile($header,\%form); print "\n"; while($set = $sth->fetchrow_hashref){ $something++; ($manufacture) = &GetBrandName($set->{'id'}); print "\n"; print "\n"; if($set->{'available'}==4){ print "\n"; } print "\n"; print "\n"; print "\n" if($set->{'warranty'}); print "\n"; } unless($something){ &NoSets(1); } print "
\n"; print "\n"; print "\n"; print "\n"; print "
$manufacture $set->{'setname'}
"; print "
\n"; print "
\n"; if($set->{'image'}){ print "{'id'}\">{'image'}\" alt=\"\" border=\"0\">\n"; } else{ print "{'id'}\">\"$set-{'setname'}\" border=\"0\">\n"; } print "
Click Image for Details
\n"; print "
\n"; print "\n"; print "On Sale Now\!\n"; print "\n"; print "
\n"; print "
$set->{'description'}
Warranty: $set->{'warranty'}

\n"; &IncludeFile($footer); } # -------------------------- sub NoSets{ my($value) = shift; my($word); if($value == 1){ $word = "sets for that manufacturer"; } elsif($value == 2){ $word = "Currently there are no books in the bookstore
Please bookmark this page now as it will change frequently."; } else{ $word = "pieces for that set"; } print "

Sorry!

\n"; print "\n"; print "
The $word are coming soon.

\n" if($value < 2); print "

$word

\n" if($value == 2); }