Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Outputing data from mySQL query into format for use with HTML::Template

by Masem (Monsignor)
on Mar 10, 2001 at 03:08 UTC ( #63395=note: print w/ replies, xml ) Need Help??


in reply to Outputing data from mySQL query into format for use with HTML::Template

A good way that I've found to do this is ...

my @values; my @fields = qw( title date ...); # what fields do you want? $sth=$dbh->prepare("SELECT " . join(',' @fields) . " FROM Videos WHER +E $FieldsN LIKE ?") or die DBI->errstr; $sth->execute( $SearchCrit ) or die DBI->errstr; while( my @vidinfo = $sth->fetchrow_array() ) { my %hash; # there's probably a better way to join these arrays, # but this is the easiest to understand OTTOMH ... # basically mapping the output to the respective field # name for ( my $i = 0; $i < @fields ; $i++ ) { $hash{ $fields[ $i ] } = $vidinfo[ $i ]; } push @values, \%hash; # push a reference to the hash onto the arr +ay } $tmpl->param( stuff = \@values );

Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain


Comment on Re: Outputing data from mySQL query into format for use with HTML::Template
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://63395]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-09-17 06:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (62 votes), past polls