soon_j has asked for the wisdom of the Perl Monks concerning the following question:
but instead, my code resulted to:Topic 1 - Item A - Item B - Item C Topic 2 - Item X - Item Y - Item Z Topic 3 - Item a - Item b - Item c
Here's a part of my code:Topic 1 - Item a - Item b - Item c Topic 2 - Item a - Item b - Item c Topic 3 - Item a - Item b - Item c
Can you help me point out the error?$y = 0; @loop = (); while($y < $x) { my %items; $items{_TOPIC} = $topic[$y]; $sth = $dbh->prepare("SELECT item1, item2, item3 FROM table WHERE +topic='$topic[$y]' ORDER BY id ASC"); $sth->execute(); @subloop = (); while(@ary = $sth->fetchrow_array()) { my %subitems; $subitems{_first_item} = $ary[0]; $subitems{_second_item} = $ary[1]; $subitems{_third_item} = $ary[2]; push(@subloop, \%subitems); } $items{_ITEMS} = \@subloop; push(@loop, \%items); $y++; } $html->param(_TOPICS => \@loop); $html->output;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI Coding Problem on Subloop
by davidrw (Prior) on Jun 17, 2006 at 20:36 UTC | |
|
Re: CGI Coding Problem on Subloop
by japhy (Canon) on Jun 17, 2006 at 21:00 UTC |