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
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] sorting a select list In reply to
perfect! thanks!