hello!
I've got the following code in my script which is working great returning a loop to my template.
The problem is that the loop variable is always positive in the template, even if there are no results in the loop - which means it always displays the first option below which is in my templates no matter if there actually are results in the loop or not. Any idea how I can fix that so that if there are no records this will work?
<%if questions_loop%>
DISPLAY 1111111111111111
<%else%>
DISPLAY 2222222222222222
<%endif%>
Code:
# Create a loop of questions my $db = $DB->table('questions');
$db->select_options("ORDER BY question_id");
my $sth = $db->select( { poll_id_fk => $poll->{poll_id} } ) || die $GT::SQL::error;
my $hits = $db->hits ;
# loop through the results and create a question loop
my @questions;
if ( $hits ) {
while (my $hash = $sth->fetchrow_hashref) {
push @questions, $hash;
}
}
# Load the poll information
print $IN->header();
print Links::SiteHTML::display('easypoll_edit', { questions_loop => \@questions , %$poll } );