It sounds more like you want the fetchall_arrayref function. This will return all the records into a single array reference that can accessed by $temp->[x][y] where x defines the record and y defines the field. For example:
my $dbh = DBI->connect('DBI:mysql:dbname','user') or die "Couldn't open database: ". DBI->errstr . "\n"; my $statement = "SELECT field1,field2,field3 WHERE field1 != \"\""; my $sth = $dbh->prepare($statement); my $rc = $sth->execute(); my $temp = $sth->fetchall_arrayref; for my $x(0..$#{$temp}) { print "$temp->[$x][0], $temp->[$x][1], $temp->[$x][2]\n" } Using an array reference as above will return all matching records in a single "container" and simplifies (in my opinion) the iteration of records. I have a PDF version of a MySQL reference manual. If you need a copy, just let me know and I'll send it to you. Also, there is another group out there ([EMAIL PROTECTED]) that may also be able to offer help. Hope this helps, Chris -----Original Message----- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 17, 2003 9:32 AM To: Benjamin Jeeves; [EMAIL PROTECTED] Subject: RE: fetchrow_array > Hi All Howdy > > I my query a MySQL database and have the following code > > while (@temp = $table->fetchrow_array ()) { > some code > { I think you mean } not { :) > > my problem is that I want the results from the database query > to be access by using $temp[0] for the first row then > $temp[1] for the second row and so on. Sure is and you've already got that: while (@temp = $table->fetchrow_array ()) { print "$temp[0] $temp[1] $temp[2] $temp[4]"; # or whatever } Outside of the while loop you'll only have one version of @temp if any, so if you need to use $temp[n] outside the while loop you'll need to assignthe values to an outside variable Perhaps a hash. If there's only going to be one record returned you can just do: my @temp = $table->fetchrow_array($query); And skip the prepare and execute stuff. Then you could use $temp[n] wherever your @temp was declared > > So is it possable to do this and if so how or where can I > find the info. > perldoc DBI HTH DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]