Welcome Guest, Not a member yet? Register   Sign In
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



Theme © iAndrew 2016 - Forum software by © MyBB