Mornin'. So, I impressed you with my blundering, eh?
I tried the while loop, but that doesn't print anything to the text file... ($Descript should be $descript in the print line.) I moved the foreach line outside the fetchrow_hashref like you suggested, making the subroutine:
$sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
!);
$sth->execute();
foreach $featured_r (sort keys %link_output) {
if ($sth->rows) {
$featured_r = $sth->fetchrow_hashref();
}
%OUT = (); # Start with a clean hash.
$OUT{ID} = $featured_r->{'ID'};
$OUT{Title} = $featured_r->{'Title'};
$OUT{URL} = $featured_r->{'URL'};
$OUT{Description} = $featured_r->{'Description'};
}
open (FEATURED, ">$LINKS{build_root_path}/featured_test.txt") or die ("unable to open featured page: $LINKS{build_root_path}/featured_test.txt. Reason: $!");
print FEATURED &site_featured_template(\%OUT);
close(FEATURED);That still only outputs one link to the file and doesn't recognize the tags:
"<a target="_blank" href="http://run-down.com/cgi-bin/runlinks/jump.cgi?ID=Unkown Tag: ID">Unkown Tag: Title</a> <BR><BR>"
How does sort keys %link_output work?
Thanks,
Dan
I tried the while loop, but that doesn't print anything to the text file... ($Descript should be $descript in the print line.) I moved the foreach line outside the fetchrow_hashref like you suggested, making the subroutine:
Code:
my ($featured_r, $sth, %OUT, %link_output); $sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
!);
$sth->execute();
foreach $featured_r (sort keys %link_output) {
if ($sth->rows) {
$featured_r = $sth->fetchrow_hashref();
}
%OUT = (); # Start with a clean hash.
$OUT{ID} = $featured_r->{'ID'};
$OUT{Title} = $featured_r->{'Title'};
$OUT{URL} = $featured_r->{'URL'};
$OUT{Description} = $featured_r->{'Description'};
}
open (FEATURED, ">$LINKS{build_root_path}/featured_test.txt") or die ("unable to open featured page: $LINKS{build_root_path}/featured_test.txt. Reason: $!");
print FEATURED &site_featured_template(\%OUT);
close(FEATURED);
"<a target="_blank" href="http://run-down.com/cgi-bin/runlinks/jump.cgi?ID=Unkown Tag: ID">Unkown Tag: Title</a> <BR><BR>"
How does sort keys %link_output work?
Thanks,
Dan