my $stmt = "SELECT xm_branches.id AS value, xm_branches.name AS branch FROM xm_users, xm_branches, xm_userbranches WHERE xm_users.username = '$user' AND xm_userbranches.user_id = xm_users.id AND xm_userbranches.branch_id = xm_branches.id"; &execute_it($stmt); $template = HTML::Template -> new(filename => "../xm_dialogs/editmenu.tmpl"); $template->param( branches => $sth->fetchall_arrayref({}));