Gossamer Forum
Quote Reply
Annoying global :(
Hi. Can anyone see anything wrong with this global? I have the following;

Code:
sub {

my $table = $DB->table('Links');
my $sth = $table->select( ['DISTINCT(State)'] ) || return $GT::SQL::error;

my $back;
while (my $hit = $sth->fetchrow_hashref) {
$back .= qq|<option>$hit->{State}</option>|;
}

}

It doesn't return anything, BUT it doesn't give an error :-/

I'm trying to get a list of States from within the database (I think the DISTINCT is working ok).

Any ideas are much appreciated...I've been racking my brain on this one for quite a while :(

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] Annoying global :( In reply to
Duh... its because I wasn't returning $back Blush (as well as the DISTINCT part not being correctly written).

The global now looks like this;

Code:
sub {

my $table = $DB->table('Links');
my $sth = $table->select( 'DISTINCT(State)' ) || return $GT::SQL::error;

my $back;
while (my $hit = $sth->fetchrow_hashref) {
next if !$hit->{State};
$back .= qq|<option>$hit->{State}</option>|;
}

return $back;

}

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!