<?php

require_once "config.php";
$id=$_POST['id'];
$msisdn=$_POST['msisdn'];
$customer_name=$_POST['customer_name'];

$invoice_no=$_POST['invoice_no'];
$sql="select * from vendor_invoice_details where invoice_no='".$invoice_no."' and  customer_name='".$customer_name."' and id!='".$id."'";
$query=mysqli_query($con,$sql);
if($result=mysqli_fetch_array($query)){
    die("Customer exists");
}
$sql="update vendor_invoice_details set invoice_no='".$invoice_no."' ,customer_name='".$customer_name."',msisdn='".$msisdn."' where id='".$id."'";
$query=mysqli_query($con,$sql);
if($query==false){
    die(mysqli_error($con));
}
echo mysqli_affected_rows($con);
$sql="update vendor_invoice_details_history set invoice_no='".$invoice_no."' ,customer_name='".$customer_name."' where customer_id='".$id."'";
$query=mysqli_query($con,$sql);
if($query==false){
    die(mysqli_error($con));
}

?>