<?php
//fetch.php
if(isset($_POST["action2"]))
{
 //$connect = mysqli_connect("localhost", "root", "", "testing");
 include('includes/config.php');
 $output = '';

if($_POST["action2"] == "vendor")
 {
  $querys = "SELECT Sum(ship_total) as totalamount FROM `shipment` as s JOIN vendors as v On s.vendor_id= v.v_id WHERE s.vendor_id = '".$_POST["query"]."' And s.s_status='1'";
  $results = mysqli_query($con, $querys);
  //$output .= '<option value="">Select Type</option>';
  
  while($rows = mysqli_fetch_array($results))
  {
    $shipmenttotal = $rows['totalamount'];
  
  
  //additional balance 
  
  $query = "SELECT sum(add_balance) as addtionalbalance FROM `vendorAdditional_balance` WHERE vendor_id= '".$_POST["query"]."'";
  $result = mysqli_query($con, $query);
  
  
  while($row = mysqli_fetch_array($result))
  {
      $newbalance =$row['addtionalbalance'];
      
      $newbal = $shipmenttotal += $newbalance;
    //$output .= '<option value="">Select Name</option>';
   $output .= '<option value="'.$newbal.'">'.$newbal.'</option>';
  }
  
  
  }
  
 }
 




 echo $output;
}
?>