At 01:27 PM 08/08/2001 +0000, David Draley wrote:
>hello -
>
>I am writing a search script that will retrieve records from an MYSQL db. I
>have used an array to store the returned records, but I am having problems
>pushing the array into a hash table. So far, my search script only returns
>the first record that matches the search criteria.
>
>-------------------------------------
>my $sth = $dbh->prepare( "SELECT * FROM survey WHERE facil =
>'$species'" );
>
>$sth->execute();
>
>@rows = $sth->fetchrow_array();
>
>
><html>.....
>
>@rows
>....</html>
You are only getting the first row of data because that is exactly what
fetchrow_array() is supposed to return when used in a list context. If you
want the whole dataset, youll have to iterate over fetchrow_array() and
push the data into an array in the loop.
Or a better way would be to use the fetchall_arrayref() method. In one fell
swoop, this will return the whole dataset with each element of the array as
a reference to each row in the dataset.
hope this helps. Aloha,
mel
--
mel matsuoka Hawaiian Image Productions
Chief Executive Alphageek (vox)1.808.531.5474
[EMAIL PROTECTED] (fax)1.808.526.4040
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]