Gossamer Forum
Home : General : Perl Programming :

sorting a select list

Quote Reply
sorting a select list
i have this global template:
sub {
my $tags = GT::Template->tags;
my $home = $tags->{home};
my $sth = $home->{sql}->table($home->{cfg}->{'user_table_use'})->select();
my @output;
while ( my $rs = $sth->fetchrow_hashref ) {
push @output, $rs;
}

return { loop_users => \@output };
}

i would like it sorted alphabetically. how? thanks
Quote Reply
Re: [delicia] sorting a select list In reply to
Hi,

I'm assuming this works like GT::SQL in GLinks/GForum... so here is my suggestion:

Code:
my $tbl = $home->{sql}->table($home->{cfg}->{'user_table_use'});
$tbl->select_options("ORDER BY your_column");
my $sth = $tbl->select();

Obviously change the bit in red to the column name you wanna sort by :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] sorting a select list In reply to
perfect! thanks!