%#-*-perl-*-
<%perl>
#my $catid = $ARGS{'catid'};
#$catid = 6 unless $catid;
print qq~
\n~;
print "
";
my $prestatement = "SELECT id FROM books_categories";
my $presth = $dbh->prepare($prestatement);
my $prerv = $presth->execute;
while (my @prerow = $presth->fetchrow_array) {
$statement = "SELECT asin,title,author,releasedate FROM books WHERE catid='$prerow[0]'";
$sth = $dbh->prepare($statement);
$rv = $sth->execute;
if ($prerow[0] == 6) {
print qq();
} else {
print qq();
}
while (my ($asin,$title,$author,$releasedate) = $sth->fetchrow_array) {
my $dbhtwo = DBI->connect($datasource, $dbusername, $dbpassword);
my $statementtwo = "SELECT rating FROM books_ratings WHERE asin='$asin'";
my $sthtwo = $dbhtwo->prepare($statementtwo);
my $rvtwo = $sthtwo->execute;
my ($rating) = $sthtwo->fetchrow_array;
my $isbn = $asin;
if (length($isbn) < 10) {
my $diff = 10 - length($isbn);
while ($diff > 0) {
$isbn = "0".$isbn;
$diff--;
}
}
if ($rating == 0) {
$rating = "Not yet rated";
} else {
$rating .= "/5";
}
print qq(

|
Author: $author
Title: $title
Published: $releasedate
Buy from Amazon
Peakinsight Rating: $rating
Rate this book
|
);
}
}
print "
";
%perl>