jptxs has asked for the wisdom of the Perl Monks concerning the following question:
I am having trouble even asking this : ) I have two tables which look like this:
i want to grab the into from table1, resolve each member of the list and get the name assoc. with it, and then print out the info like:Table1: act1 | act2 | act3 | act4 _________________________ 1,2 | 3,2 | 6 | 2,8 Table2: id | name _________ 1 | foo 2 | bar 3 | this 6 | that 8 | hey
I tried and failed four times, I keep getting a bunch of ARRAY(XXXXXX) stuff and I am clueless as to why here is the code i tried:1 : act1 2 : act1, act2, act4 3 : act2 6 : act3 8 : act4
$req_cert_info->execute("$TRANS_ID") or dienice("344 Couldn't execute statement $TRANS_ID : " . $get_info-> +errstr); my %seen; while ( my $ref = $req_cert_info->fetchrow_hashref ) { foreach my $key ( keys %$ref ) { next if ( $key eq "TRANS_ID" ); if ( $ref->{$key} ) { my @prod_ids = split ",", $ref->{$key}; foreach my $prodid ( @prod_ids ) { my $prod; if ( exists $seen{$prodid} ) { $prod = $seen{$prodid}; } else { my $prod = $dbh->selectrow_array("SELECT PRODUCT F +ROM SC_PRODUCT WHERE PRODUCT_ID = $prodid"); push @{$seen{$prodid}}, $prod; } push @{$services{$prod}}, $key; } } } } $req_cert_info->finish; foreach my $product ( keys %services ) { print "<TR><TD>@{$product}</TD><TD>@{$services{$product}}</TD><TD> +checkbox</TD></TR>"; }
I hope this is clear enough - I think part of the problem is I am so unclear on it myself. I thank anymonk who can help : )
-- I'm a solipsist, and so is everyone else. (think about it)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: reversing a hash -- printing it
by extremely (Priest) on Oct 13, 2000 at 02:39 UTC | |
by jptxs (Curate) on Oct 13, 2000 at 17:00 UTC | |
by jeffa (Bishop) on Oct 13, 2000 at 18:02 UTC | |
by jptxs (Curate) on Oct 14, 2000 at 07:39 UTC | |
|
Re: (SOLVED : ) )reversing a hash -- printing it
by jptxs (Curate) on Oct 13, 2000 at 01:59 UTC | |
|
Re: reversing a hash -- printing it
by jptxs (Curate) on Oct 13, 2000 at 01:25 UTC |