Hi, I'm fairly new to perl and wondering if I could ask a little assistance in making my script work. I've got an array full of 7 character codes and this is my attempt to have the first three codes equivalent database entries be returned in .html format. It works fine when I'm having the sth->fetchrow_array assign to an array, but now I've used a hash the counter I've set has gone bonkers and it isn't behaving the way I thought it would and I really can't see why. My intended out put is as follows

<tr> <td>AccNo</td> <td>$result[0]</td> </tr> <tr> <td>GeneLocus</td> <td>data</td> </tr> <tr> <td>aaSequence</td> <td>data</td> </tr> <tr> <td>AccNo</td> <td>$result[1]</td> </tr> <tr> <td>GeneLocus</td> <td>data</td> </tr> <tr> <td>aaSequence</td> <td>data</td> </tr> <tr> <td>AccNo</td> <td>$result[2]</td> </tr> <tr> <td>GeneLocus</td> <td>data</td> </tr> <tr> <td>aaSequence</td> <td>data</td> </tr>

When I change the counter, it changes the number of rows, rather the number of sets of rows printed. I'm baffled. Thanks very much for your help in advance

$i=0; my %germline; my @key = ('AccNo', 'GeneLocus', 'aaSequence'); # get top 3 fasta-result-hit rows from germline dB until($i==3){ my $sql = "SELECT DISTINCT AccNo, GeneLocus, aaSequence FROM aaSEQ + a, Ig_functional b WHERE a.aaID = b.RecNo AND AccNo = '$result[$i]';"; my $sth = $dbh->prepare($sql) or die "Could not prepare statement: + " . $dbh->errstr; if ($sth->execute){ while (($germline{AccNo}, $germline{GeneLocus}, $germline{aaSe +quence}) = $sth->fetchrow_array){ print "<tr>\n<td>$key[$i]</td>\n<td>$germline{$key[$i]}</t +d>\n</tr>\n\n"; } } $i++; } $dbh->disconnect();

In reply to Looping loops by ribonuceloside

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.