<?php

include_once("connectioni.php");

$sql="select * from paymas  where  bea1!='' and vatno!='' order by bdate desc";
			$result=mysqli_query($GLOBALS['dbacc'],$sql);
			while($row = mysqli_fetch_array($result)){

			$sql2="select * from  che_customers  where chepay='".$row["bea1"]."' ";
			$result2=mysqli_query($GLOBALS['dbacc'],$sql2);
			if ($row2 = mysqli_fetch_array($result2)){
				echo $row2["chepay"];
			}
		$sql1="update che_customers set vat='".$row["vatno"]."'  where chepay='".$row["bea1"]."' ";
			$result1=mysqli_query($GLOBALS['dbacc'],$sql1);
			//echo $sql1;
			
			}

			
?>