in reply to How to reach each element of 2d-array retrieved from Mysql query?

You're performing the query and the fetch in a single step. Every time the loop executes you repeat the query and the fetch starts back at the beginning.

You have to execute the query outside the loop, then execute the FetchRow within the loop
my $q = $dbh->Query("select s.sect, s.test, t.name, t.res_tbl t.f_num +fro +m s_lab_recs s, tests t where s.s_lab_id=$id and s.sect=t.sect_id"); while(my @row = $q->FetchRow) { push @sect, $row[0]; push @test, $row[1]; }
  • Comment on Re: How to reach each element of 2d-array retrieved from Mysql query?
  • Download Code

Replies are listed 'Best First'.
Re^2: How to reach each element of 2d-array retrieved from Mysql query?
by Anonymous Monk on May 26, 2006 at 01:56 UTC
    Thank You very much, ruzam! It worked!