> > How did you plan on *retrieving* the data if not through a loop? If you
> > plan on actually getting all the data, you'll have to loop through all the
> > rows I think. Maybe you could post a code fragment?
>
> here is the old code... based ob a file
>
> my @data=split(/\r?\n/,$part[2]);
>
> if ($data[2] ne '') {
> my @datas=split(';',$data[2]);
> print "Counted Items ";print $#datas+1;print" Items<BR>\n";
> print "Inside: ";foreach (sort @datas) {print "Item: $_ ";} print "<BR>\n";
> }
Not sure I see your problem. Rather than splitting from a file, you're
selecting from an array. Instead of doing a foreach{} loop you just do a
while loop. Doesn't change the logic at all.
my $sql = 'SELECT field FROM DATA ORDER BY field';
my $sth = $dbh->prepare($sql);
$sth->execute();
while (my $row = $sth->fetchrow_array()) {
$i++;
$html .= "Item: $row ";
}
print "Counted Items $i Items<BR>",
"Inside $html<BR>";