in reply to HTML::Template: Howto make a inner/outer loop?
my $dbh = DBI->connect( qw(DBI:mysql:database:host user pass), #substitute your values here {RaiseError => 1 }, ); my $sections = $dbh->selectall_arrayref(' SELECT id, title FROM sections ',{Slice => {}}); for my $section (@$sections) { my $pages = $dbh->selectall_arrayref(' SELECT SELECT title FROM pages WHERE sectionid = ? ',{Slice => {}}, $section->{id}); $section->{pages} = $pages; } my $tmpl = HTML::Template->new(filehandle => \*DATA); $tmpl->param(sections => $sections); print $tmpl->output; __DATA__ <ul> <tmpl_loop sections> <li>Section: <tmpl_var title> <ul> <tmpl_loop pages> <li>Page: <tmpl_var title></li> </tmpl_loop> </ul> </tmpl_loop> </ul>
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|