Wow! Thanks for getting back to me so quickly. I really appreciate it.
> Can you describe what you mean by "not working properly"?
To put it simply, it's not working at all. No code is generated, at all.
So as to help you diagnose the problem, let me show you how I'm doing this:
sub get_questions {
...<do the SELECTing, etc.>...
my @qrefs;
my $count = 0;
for (my $x=0; $x<5; $x++)
{
my $ref = $qry->fetchrow_hashref();
$qrefs[$count] = $ref;
++$count;
}
return(@qrefs);
}
sub display_questions(@refs)
{
my @refs = @_;
print header(), start_html('RLDS Trivia Questions');
my $template = HTML::Template->new(filename =>
'/home/www/elderlinda/quiz-template.tmpl');
for (my $x=0; $x<5; $x++)
{
$template->param(Q => \@refs);
}
print $template->output;
}
<down in main program logic>
my @refs = get_questions();
display_questions(@refs);
Hopefully that code falls under the category of "small working examples that
demonstrate your problem", not "your whole 1000 line CGI". ;-)
> An array of references to hashes is perfect, but you should read the docs
> for DBI::fetchrow_hashref. My memory is that it will return a reference
> to the same hash everytime. I think you'll need to make a private copy of
> the hash or you'll end up with an array containing a list of references to
> the last row in your dataset!
Hmmm...worth checking out, thanks.
> I can't see anything wrong with the code here, but I don't have enough
> information to diagnose your problem. One question - why would you define
> multiple loops with different names and the same data? You can re-use a
> loop in a template as many times as you like.
That wasn't very clear from the documentation. That's not to say it's bad
documentation -- heaven knows, I've written documentation myself, and it's
tough to make it perfect -- just that it didn't come across to me very well.
If you'd be interested, though, I'd be happy to write you up an addendum to
the documentation detailing how to do this, once I get it working.
Thanks Again,
Alex Kirk
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]