zetetes has asked for the wisdom of the Perl Monks concerning the following question:
sub doNavigation { my $root = $_[0]; my $select = "f2c_id,f2c_fatherid"; my $from = "t_father2child"; my $where = "f2c_id = $root"; my @fathers = doSelect($select,$from,$where); my $fatherId = $fathers[0][1]; loop($root,$fatherId); } # end sub sub loop { my $root = $_[0]; my $father = $_[1]; my $select = "f2c_id,f2c_fatherid,f2c_childid,element_titel"; my $from = "(t_father2child INNER JOIN t_element ON f2c_ChildId = el +ement_id)"; my $where = "f2c_fatherid = $father AND f2c_NodeTypeId = 1"; my @nodes = doSelect($select,$from,$where); foreach my $node (0..$#nodes) { print "<br><a href=?node_id=$nodes[$node][0]> - $nodes[$node][1] - + $nodes[$node][2] - $nodes[$node][3]</a>"; if ($nodes[$node][0] == $root) { my $select = "f2c_id,f2c_fatherid,f2c_childid,element_titel"; my $from = "(t_father2child INNER JOIN t_element ON f2c_ChildId += element_id)"; my $where = "f2c_fatherid = $nodes[$node][2] AND f2c_NodeTypeId += 1"; my @children = doSelect($select,$from,$where); if (@children) { loop($root,$children[0][1]); } # end children-if } # end node-if } # end node-foreach }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: nested navigation links
by matija (Priest) on Mar 25, 2004 at 14:21 UTC | |
by zetetes (Pilgrim) on Mar 25, 2004 at 14:33 UTC |