in reply to HTML::Template : generation of links
select distinct site_name from sites order by site_name; select distinct router from sites where site_name = ?; select interface from sites where site_name = ? and router = ?but i don't really see much that we can do about it right now. In the meantime, why don't you try a simpler approach instead. Untested:
use DBI; use HTML::Template; my $dbh = DBI->connent( qw(dbi:mysql:ndb user pass), {RaiseError => 1}, ); my $sites = $dbh->selectall_arrayref(' select distinct site_name as name from sites order by site_name ',{Slice=>{}}); for my $site (@$sites) { $site->{routers} = $dbh->selectall_arrayref(' select distinct router as name from sites where site_name = ? ',{Slice => 1}, $site->{name}); #i removed the router = ? part from here #how do you expect to query a single router if there are multiples? $site->{interfaces} = $dbh->selectall_arrayref(' select interface as name from sites where site_name = ? ',{Slice => 1}, $site->{name}); } my $tmpl = HTML::Template->new(filehandle => \*DATA); $tmpl->param(sites => $sites); print $tmpl->output; __DATA__ <tmpl_loop sites> Name: <tmpl_var name> Routers: <tmpl_loop routers> <tmpl_var name> </tmpl_loop> Interfaces: <tmpl_loop interfaces> <tmpl_var name> </tmpl_loop> </tmpl_loop>
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)
|
---|