sub getarticles { + my $article = shift; + my $query = qq(SELECT reply FROM replies WHERE article=$articl +e 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; + }
This produces output like this:
First comment First reply Second reply First reply to Second reply above Second reply to Second reply above Third reply
I would like to know how I could produce output similar to the unix "tree" program, ie with lines to indicate relationships between nodes:
And any other observations you might care to make. TIA.First comment `-------First reply `-------Second reply | `-------First reply to Second reply above | `-------Second reply to Second reply above `-------Third reply
2001-03-04 Edited by Corion : Changed <PRE> tags to <CODE> tags.
In reply to Graphical Hierarchical Tree by yojimbo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |