use CGI ;
use DBI;
use strict;

my $data_source = "dbi:Pg:dbname=rotb;host=rdbms";
my $username    = "magnus";
my $auth        = "foo";

my ($q, $page, $dbh);

$q = new CGI || die;
$page = (defined $q->param("page")?$q->param("page"):0);

# CONNECT TO THE DATABASE
$dbh = DBI->connect($data_source, 
		    $username, 
		    $auth) ||die ("couldn't connect to database: ".$DBI::errstr);

print $q->header(),
    $q->start_html("Reviews of This Book");

my $sth = $dbh->prepare("SELECT html FROM reviews WHERE id > ? AND id < ? ORDER BY seq,id");
my $ret = $sth->execute($page*2000, ($page+1)*2000);

while (my ($res) = $sth->fetchrow_array) {
    print "<p> $res </p>";
}


foreach my $i (1..5) {
    print <<EOF
    <p> Although each review in this book contributes to the one following it, it seems to me that eventually, a general consensus will occur, a meta-literary eigenvector, such as it were.</p>
EOF
    ;
}
print 
    "<p>...</p>",
    "<hr>",
    "<a href=\".\">Front matter</a> | ",
    "<a href=\"review.pl\">Review this book</a>";



