<?php

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

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


    $mainqry = mysqli_query($conn, "SELECT examcode, vouchno FROM `demdmain` having MAX(`vouchno`)")or die(mysqli_error($conn));
    $fmain = mysqli_fetch_array($mainqry);
    
    $code = $fmain['vouchno'];
    $examcode = $fmain['examcode'];

    $getexam = mysqli_query($conn, "SELECT code, name FROM exam WHERE code = '$examcode' ")or die(mysqli_error($conn));
    $fexam = mysqli_fetch_array($getexam);
    $examname = $fexam['name']; 
    
    $rows = array();
    $rows = array('code' => "$code",
                  'exam' => "$exam"
    );
    header("Content-type: application\json");
    echo json_encode($rows);
