What is the following code supposed to do?
foreach $i(0..$#{$rows}) { foreach $j (0..$#{$rows->[$i]} ) { $rows->[$i][$j]; } }
Answer: Each time the code runs I select distinct(id) from table. When I fetch the id's and put them into an array, they are all placed into array index '0'. I want to pass individual id's to the sql statement so I add indexes by the above logic where I iterate through by incrementing $i++.
Have you tried replacing the query results with hardcoded data? Does the program work then as you want it to?
while ($i<=2) { my $placeholder = ":p_$j"; print "$placeholder\n"; my $rd = "$rows->[$i][0]"; print "$rd\n";
Answer: Yes. I can set the rd to equal a specific value and it returns the value result. If the array = ('A01','B88','C88',....'nth'), I want to only select * from table where id = 'A01'; pass 'A01' to email, then 'B88'....then 'C88'....'nth'.
The while loop iterates through the array and changes the index value. The value changes as $i increments. The problem is the sql code only returns data for the first array index. All of the print statements change. All of the emails and spreadsheet data is changed. but only the first array index is populated in the emailed spreadsheets.
In reply to Re^4: SQL query using dynamic array
by cocl04
in thread SQL query using dynamic array
by cocl04
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |