<?php

ob_start();
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');

$maindb = "cashrecp";
$billdb = "billsett";

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);

$getpmain = mysqli_query($conn, "SELECT vouchno, examcode  FROM `$maindb` ") or die(mysqli_error($conn));

while ($row = mysqli_fetch_array($getpmain)) {
      $vouchno = $row['vouchno'];
      $exam = $row["examcode"];

      mysqli_query($conn, "update `billsett` set examcode = '$exam' WHERE bnkvouch = '$vouchno' and source = 'CR' ") or die(mysqli_error($conn));
    
}
browse('Cash Completed') ;

$getbmain = mysqli_query($conn, "SELECT vouchno, examcode  FROM `bankrecp` ") or die(mysqli_error($conn));

while ($rowb = mysqli_fetch_array($getbmain)) {
      $vouchno = $rowb['vouchno'];
      $exam = $rowb["examcode"];

      mysqli_query($conn, "update `billsett` set examcode = '$exam' WHERE bnkvouch = '$vouchno' and source = 'BR' ") or die(mysqli_error($conn));
    
}

browse('Bank Completed') ;