David Draley <[EMAIL PROTECTED]> said something to this effect on 08/08/2001:
> 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.

You have the right idea.  fetchrow_array returns each row as an
array, not the whole result set as an array.  Try
$dbh->selectall_arrayref (or $dbh->selectall_hashref if you have
a new enough version of DBI) to get the entire set.

> -------------------------------------
> my $sth = $dbh->prepare( "SELECT * FROM survey WHERE facil =  '$species'" );
> 
> $sth->execute();
> 
> @rows = $sth->fetchrow_array();
> 
> 
> <html>.....
> 
> @rows
> ....</html>

$rows = $dbh->selectall_arrayref("SELECT * FROM survey WHERE facil =  '$species'");

now $rows looks like (I'll make up some data):

$rows = [
            [
              1, 2, 3, 4,
            ],
            [
              5, 6, 7, 8,
            ],
          ];

The downside is you can't just print it.

(darren)

-- 
All truth passes through three stages: first, it is ridiculed; next it
is violently attacked; finally, it is held to be self-evident.
    -- Schopenhauer

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to