Thanks for the continued efforts. I'm still not having any luck with this... I tried several variations of your last suggestion, and all of them print out a blank text file.
# --------------------------------------------------------
# Creates a featured sites page.
#
my ($featured_r, $sth, %OUT, %link_output);
$sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
!);
$sth->execute();
%OUT = (); # Start with a clean hash.
open (FEATURED, ">$LINKS{build_root_path}/featured_test.txt") or die ("unable to open featured page: $LINKS{build_root_path}/featured_test.txt. Reason: $!");
foreach $featured_r (sort keys %link_output) {
if ($sth->rows) {
$featured_r = $sth->fetchrow_hashref();
}
$OUT{ID} = $featured_r->{'ID'};
$OUT{Title} = $featured_r->{'Title'};
$OUT{URL} = $featured_r->{'URL'};
$OUT{Description} = $featured_r->{'Description'};
print FEATURED &site_featured_template(\%OUT);
}
close(FEATURED);
}I also tried moving the closing "if" bracket to after the print line, but it made no difference. The only thing I can think is that when it printed a single record correctly,
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
!);
$sth->execute();was not separated from the rest by the foreach loop. However, moving it inside the loop still prints a blank text file. Any other thoughts?
As far as the %db_select_fields, I have isFeatured set up just the same as the other fields such as isPopular, the only difference being that "Form Length" is set to "3" instead of "0". Setting it to "0" just makes a smaller text entry box; doesn't make it a dropdown box. Surely there's another way of doing this...
Dan
Code:
sub is_featured { # --------------------------------------------------------
# Creates a featured sites page.
#
my ($featured_r, $sth, %OUT, %link_output);
$sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
!);
$sth->execute();
%OUT = (); # Start with a clean hash.
open (FEATURED, ">$LINKS{build_root_path}/featured_test.txt") or die ("unable to open featured page: $LINKS{build_root_path}/featured_test.txt. Reason: $!");
foreach $featured_r (sort keys %link_output) {
if ($sth->rows) {
$featured_r = $sth->fetchrow_hashref();
}
$OUT{ID} = $featured_r->{'ID'};
$OUT{Title} = $featured_r->{'Title'};
$OUT{URL} = $featured_r->{'URL'};
$OUT{Description} = $featured_r->{'Description'};
print FEATURED &site_featured_template(\%OUT);
}
close(FEATURED);
}
Code:
$sth = $LINKDB->prepare (qq! SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
!);
$sth->execute();
As far as the %db_select_fields, I have isFeatured set up just the same as the other fields such as isPopular, the only difference being that "Form Length" is set to "3" instead of "0". Setting it to "0" just makes a smaller text entry box; doesn't make it a dropdown box. Surely there's another way of doing this...
Dan