Hi,
my database is organized such that every page has a hierarchical superior page
("mother"). When displaying a page, a little drop-down menu should be displayed
with all the mother, grandmothers etc. until the loop hits a page of the root
type (and unless the page itself is a root page).
I currently generate the menu like this:
sub pathmenu {
my ($mutterid, $page_type) = @_;
my ($muttertype) = $dbh->selectrow_array("SELECT page_type FROM pages WHERE
page_id = $mutterid");
my $mutterpfad;
return $mutterpfad if $page_type == 2 || $muttertype == 2;
$mutterpfad = qq{<div class="pathmenu"><form action="/cgi-bin/show.pl"
method="post" enctype="application/x-www-form-urlencoded"
accept-charset="utf-8"><select name="id" onchange="submit()"><option
value="$page_hash->{mother_id}">Pfad</option>} unless $page_hash->{mother_id}
== 1;
while ($mutterid) {
my ($mother_title, $uebermutter, $muttertype) =
$dbh->selectrow_array("SELECT title, mother_id, page_type FROM pages WHERE
page_id = $mutterid");
last if $muttertype == 2;
$mutterpfad .= qq{<option value="$mutterid">$mother_title</option> };
$mutterid = $uebermutter;
}
$mutterpfad .= qq{</select> <input type="submit" name="Up" value="Up!"
/></form></div>};
return $mutterpfad;
}
Is there a better way to do this? There certainly is, and I am grateful for
pointers.
Thanks,
Jan
--
Common sense is what tells you that the world is flat.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>