<?php 
include("config.php"); 

$blquery = mysqli_query($conn,"select * from billing order by id");
$bl = mysqli_num_rows($blquery);
$data = array();

while ($rows = mysqli_fetch_array($blquery)) {
	$data[] = $rows;
}

foreach ($data as $key => $datas) {
   $vendor = "SELECT * FROM `vendor_master` WHERE `id` = '".$datas['vendor_id']."'";
   $ven_res = mysqli_query($conn,$vendor);
   $ven_row = mysqli_fetch_array($ven_res);
		
   $act_msetr = "SELECT * FROM `act_master` WHERE `ac_name` = '".$ven_row['name']."'";
   $act_ma_res = mysqli_query($conn,$act_msetr);
   $act_ma_row = mysqli_fetch_array($act_ma_res);
   $vendor_code = $act_ma_row['act_code'];

   $update_trans =  "UPDATE `trans` SET `act_code`='".$vendor_code."'
                    WHERE voucher_no = '".$datas['invoice_no']."'";
   $upedate_res = mysqli_query($conn, $update_trans);
}

?>


