i'm trying to populate an array with a reference to array returned by:fetchrow_array so that I can use the values more than once during in script
if i then:
print "$rowResults[0]<p>";
print "$rowResults[1]<p>";
print "$rowResults[2]<p>";
the results that are printed are only the first column of each row. not sure why the other 6 columns are not being populated into the array.
any help would be helpful. thanks.
Code:
$counter = 0;
foreach $addedProduct (@cartData)
{
my $query = "Select column1, column2, column3, column4, column5, column6, column7 from tableName where id ='$id_value'";
$sth = $dbh->prepare($query);
if (!$sth) { die "Illegal query: $query" };
$sth ->execute;
while (@row = $sth->fetchrow_array) {
@rowResults[$counter] = @row;
}
$sth->finish;
$counter=$counter+1;
}
print "$rowResults[0]<p>";
print "$rowResults[1]<p>";
print "$rowResults[2]<p>";
the results that are printed are only the first column of each row. not sure why the other 6 columns are not being populated into the array.
any help would be helpful. thanks.