<%method doctype> <%init> use DBI; use strict; use warnings; # Get Books my $q = $dbh->prepare("SELECT book.id AS id, book.title AS title, author1 AS author1id, person.name AS author, (SELECT person.name FROM person WHERE author2 = person.id) AS author2, (SELECT person.name FROM person WHERE author3 = person.id) AS author3 FROM book,person WHERE person.id = book.author1 ORDER BY person.name"); $q->execute or die "ERROR: couldn't query for Books! " . $dbh->errstr; my $qnum = $dbh->prepare("SELECT ref FROM special WHERE thetable = 'person' AND ref =?"); [vs] Books

[vs] Books

% while( my $hr = $q->fetchrow_hashref ){ % $qnum->execute($hr->{author1id}) or die "ERROR: couldn't query for Books! " . $dbh->errstr; % if ($qnum->rows == 0) { % } else { % }; % };
<% $hr->{id} %> <% $hr->{title} | h %><% $hr->{author} %><% $hr->{author2} %><% $hr->{author3} %><% $hr->{author} %><% $hr->{author2} %><% $hr->{author3} %>
<& special.mas, table=>'book', ref=>$hr->{id} &>
<%method kata>unmedia.phtml