NodeReaper has asked for the wisdom of the Perl Monks concerning the following question:

  • Comment on outputting data from mySQL to html template

Replies are listed 'Best First'.
Re: outputting data from mySQL to html template
by princepawn (Parson) on Mar 10, 2001 at 02:51 UTC
    A few administrivia:
    1. I dont think the particular database you are using is relevant-enough to be in the title.
    2. I would have written "html template" as "HTML::Template"

    anyway, why dont you use selectrow_hashref and push the hashrefs onto an array like this:

    $dbh=DBI->connect($datasource,$user,$pass,{AutoCommit=> 1}) or die "Ca +n't Connect"; $sth=$dbh->prepare("SELECT * FROM Videos WHERE $FieldN LIKE ?") or die +; $sth->execute($SearchCrit); my @template_data; while (my $hashref = $sth->select_hashref()) { push @template_data, $hashref; } $tmpl->param( stuff => \@template_data);
    You could also ask this question on the HTML::Template mailing list. But you get faster responses here.