in reply to Outputing data from mySQL query into format for use with HTML::Template
Assuming the fieldnames in your template are the same as the fieldnames in your database, you can do:
$sth->execute( $SearchCrit ); my @results = (); while ( my $row = $sth->fetchrow_hashref ) { push @results, \%{ $row }; } $tmpl->param( stuff => \@results ); ...
This isn't the most efficient but it's the easiest to understand. (And for small datasets like putting tables of data in a web page, you probably won't notice the difference.)
Note that if you try a shortcut and push $row directly into @results you'll get the same row over and over.
Chris
M-x auto-bs-mode
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Outputing data from mySQL query into format for use with HTML::Template
by sutch (Curate) on Mar 10, 2001 at 05:52 UTC |