Hi,
How do I use a variable I’ve defined in While loop outside of said loop? I’m using it to push a bunch of values into an array, and then I need to echo that array in another while loop. I don’t want to bore you with too many details, so I’ll put some example code to show what I mean.
[php]
<?php
// Obviously most of the variables are gibberish, but I thought this might help.
while ($query_row_2 = odbc_fetch_array($qr_2)) {
while ($sum_row = odbc_fetch_array($qr_2)) {
$r01 = array();
$r01_push = array_push($r01, $sum_row['SC01058']);
$r01 = array_sum($r01); // The variable I need to use.
}
echo '
'.$query_row_2['SC01001'].' |
'.$query_row_2['SC01002'].$query_row_2['SC01003'].' |
'.$query_row_2['SC01058'].' |
'.$r01.' | // Where I need to use said variable.
';
}
?>
[/php]