• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can i use variable from diffrent foreach to get value by adding 2 variable itself

#2
Declare your variables outside of the foreach loop.

PHP Code:
$untung 0;
$ongkir 0;

foreach (
$sum->result() as $row) {
  
$untung=$row->jumlah_item;    
}

foreach (
$sumongkir->result() as $row) {
  
$ongkir=($row->total);
}

$total=$untung+$ongkir
Reply


Messages In This Thread
Declare variables outside of loop - by JayAdra - 09-28-2015, 05:18 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.