<?php
include("db.php");
     $findCurrency_Sql="select distinct currencyId from customerbalance";
     $findCurrency_Query= $db ->query($findCurrency_Sql);
	 while($findCurrency_Row=$findCurrency_Query ->fetch_array()){

      $findCurrency=$findCurrency_Row['currencyId'];
 	  //==========================finding Currency Rate=========================
     //============================account Payable============================
	  $dollarPayable_sql="select sum(dollarAmount) from customerbalance where dollarAmount>0 and currencyId='$findCurrency'";	
	  
	  $dollarPayable_Query= $db ->query($dollarPayable_sql);
	  $dollarPayable_Row=$dollarPayable_Query ->fetch_array();
	  $all_sumdollarPayable=$dollarPayable_Row['sum(dollarAmount)'];
	  
	  $all_dollarPayable=$all_sumdollarPayable;
	
	  $all_totaldollarPayable+=$all_dollarPayable; 
	//============================account Payable============================
	  $dollarrecivable_sql="select sum(dollarAmount) from customerbalance where dollarAmount<0 and currencyId='$findCurrency'";	
	  $dollarrecivable_Query= $db ->query($dollarrecivable_sql);
	  $dollarrecivable_Row=$dollarrecivable_Query ->fetch_array();
	  $all_dollarrecivable=$dollarrecivable_Row['sum(dollarAmount)'];
	  
	  $all_sumDollarRecivable=$all_dollarrecivable;
	
	  $all_totaldollarRecivable+=$all_sumDollarRecivable;
		
     }
    
    $all_totaldollarPayable;
	$all_totaldollarRecivable;
		//echo "<br>======================================</br>";   

?>