in reply to AoH refs for setting HTML::Template loops
Oh - you probably will want to, at some point, change your database.
CREATE TABLE USER_BRANCH_XREF ( USER VARCHAR2(20) NOT NULL REFERENCES USERS(USERNAME) ,BRANCH NUMBER NOT NULL REFERENCES BRANCHES(ID) ,CONSTRAINT PRIMARY KEY (USER, BRANCH) );
SELECT branches.id AS value ,branches.name AS branch FROM users ,branches ,user_branch_xref WHERE users.username = ? AND user_branch_xref.user = users.username AND user_branch_xref.branch = branches.id
Putting it all together, you would have:
my $sql = <<__END_SQL__; SELECT branches.id AS value ,branches.name AS branch FROM branches ,user_branch_xref WHERE user_branch_xref.user = ? AND user_branch_xref.branch = branches.id __END_SQL__ my $sth = $dbh->prepare_cached( $sql ) or die $DBI::errstr; $sth->execute( $user ) or die $DBI::errstr; my $template = HTML::Template -> new( filename => "../xm_dialogs/editmenu.tmpl", ); $template->param( branches => $sth->fetchall_arrayref( {} ), );
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
|
|---|