while( @row=$dbh->Query("select s.sect, s.test, t.name, t.res_tbl t.f_num from s_lab_recs s, tests t where s.s_lab_id=$id and s.sect=t.sect_id")->FetchRow ){ @cont=\@row; push @sect, $cont[0]; push @test, $cont[1]; }