sub getarticles { my $article = shift; my $query = qq(SELECT reply FROM replies WHERE article=$article ORDER BY reply); my $sth = $dbh->prepare($query); $sth->execute; $sth->rows or return 0; while (my $reply = $sth->fetchrow) { my $query = qq(SELECT timestamp, subject, author FROM article WHERE id=$reply); my $sth = $dbh->prepare($query); $sth->execute; my ($timestamp, $subject, $author) = $sth->fetchrow; $sth->finish; ( code to show the retrieved items as html, snipped ) $indent++; &getarticles($reply); $indent--; } $sth->finish; return; } #### First comment First reply Second reply First reply to Second reply above Second reply to Second reply above Third reply #### First comment `-------First reply `-------Second reply | `-------First reply to Second reply above | `-------Second reply to Second reply above `-------Third reply