<?
session_start();
include_once('opendb.php');
$sql="select kgst,acname from customer where kgst > '' order by acname";
$sql_tbl=mysqli_query($db,$sql);
$i=1;
while($rrow=mysqli_fetch_array($sql_tbl))
{
    $sql1="update spareinvoice set engineer ='$rrow[0]' where customer = '$rrow[1]'";
    mysqli_query($db,$sql1);
    print $sql1 ."<br>";
    $sql1="select distinct invno,brcode from jobcard where cname = '$rrow[1]'";
    $sql_tbl1=mysqli_query($db,$sql1);
    while($rrow11=mysqli_fetch_array($sql_tbl1))
    {
        $invno = $rrow11[0];
        $brcode11 = $rrow11[1];
        $sql="update jcardparts set pan = '$rrow[0]' where invno = '$invno' and brcode= '$brcode11";
        print $i++.$sql."<br>";
        mysqli_query($db,$sql);
    }
}

?>