in reply to Re: Beginner question about displaying database contents using HTML Template
in thread Beginner question about displaying database contents using HTML Template

Here's where I am at now: I think I am still unsure about how to preserve the ORDER BY once I display the results of the template. Any advice????????
sub displayphone { #Retrieve current state of the object my $self = shift; #Shortcut to return a reference to an array of hash elements my %attr = ( dbi_fetchall_arrayref_attr => {}); #Preparing the template and substitute the values my $template = HTML::Template->new(filename => 'displayphone.tmpl' +); $template->param(ROWS => $dbh->selectall_arrayref("SELECT * FROM d +irectory ORDER BY lastname", \%attr, $value),); #Display results return $template->output; }
  • Comment on Re^2: Beginner question about displaying database contents using HTML Template
  • Download Code

Replies are listed 'Best First'.
Re^3: Beginner question about displaying database contents using HTML Template
by jZed (Prior) on Jul 20, 2006 at 18:23 UTC
    If you retrieve your results into an arrayref (e.g. with selectall_arrayref), the rows in the array will be in the order returned by the SQL query, in this case ordered by lastname. If you use TMPL_LOOP to display the arrayref, it will display the results in the order they occur in the arrayref. What's the problem?