On Wed, 8 Aug 2001, David Draley wrote:
> -------------------------------------
> my $sth = $dbh->prepare( "SELECT * FROM survey WHERE facil =
> '$species'" );
>
> $sth->execute();
>
> @rows = $sth->fetchrow_array();
>
>
> <html>.....
>
> @rows
> ....</html>
You need to loop through your result set until there's no more to
retrieve. Each retrieval will only yield one row, so you need to process
each row individually:
while(my @row = $sth->fetchrow_array) {
foreach (@row) { print $_, "\n" }
}
However, if you are putting this into a hash ultimately, you should use
fetchrow_hashref, and then you can retrieve the data by column name, if
necessary (using arrays is faster, though).
while( my $row = $sth->fetchrow_hashref) {
foreach my $col (keys %{$row} ) {
print "$col = $row->{$col}\n";
}
}
Do you have Tim Bunce's DBI book? If you don't, get it! It's a lot nicer
to learn DBI than the perldocs are.
-- Brett
http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
Question: Is it better to abide by the rules until they're changed or
help speed the change by breaking them?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]