Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

generate full category list code

Quote Reply
generate full category list code
hello

I have the following in part of a script (not as a global) that I copied from another post in the forum. Problem is... its not working for me - returns nothing to the page. Can anyone see any problem with it?

Code:

my $cat_db = $DB->table('Category');
$cat_db->select_options ("ORDER BY Full_Name DESC");
my $sth = $cat_db->select ();
my $output .= "<select name='catid'>";
while (my $cat = $sth->fetchrow_hashref) {
$output .= "<option value='$cat->{ID}'>$cat->{Name}</option>";
}
my $output .= "</select>";
print "$output";

thank

r

Last edited by:

ryel01: Aug 8, 2004, 3:50 AM
Quote Reply
Re: [ryel01] generate full category list code In reply to
Hi. I would use;

Code:
my $cat_db = $DB->table('Category');
$cat_db->select_options ("ORDER BY Full_Name DESC");
my $sth = $cat_db->select ();
my $output .= "<select name='catid'>";
while (my $cat = $sth->fetchrow_hashref) {
$output .= qq|<option value='$cat->{ID}'>$cat->{Name}</option>|;
}
$output .= q|</select>|;
print $output;

You had 2 declerations of $output, so it was simply overwriting the list :p

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] generate full category list code In reply to
Blush