I want to get the value from an array thats in a while fetchrow.. if that makes sense.
heres my code and the output to help explain
while (@data = $STH2->fetchrow_array()) {
print "<tr>";
print "<td>$_</td>" for @data[0,1];
print "</tr>";
and this outputs
$data[0] | $data[1]
1 | 1000
1 | 400
12 | 500
12 | 150
(each $data[0] will only output 2 values)
what i want to do is subtract the 2 $data[1] values from each other (ie. 1000-400) for each different $data[0] value then print that. I cant figure out how to do this, thank you for any help.
Just capture the values in a hash of array references and then do the subtraction later (Warning: Untested):