<?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];
$tour = $_REQUEST['tour'];
$gen1 = mysqli_query($conn, "SELECT MAX(vouchno) AS maxcode FROM `visaform` WHERE `tour` = '$tour'  LIMIT 0,1 ") or die(mysqli_error($conn));
if (mysqli_num_rows($gen1) > 0) {
    $vvouch3 = mysqli_fetch_assoc($gen1);
    $qvouch3 = $vvouch3["maxcode"] + 1;
} else {
    $qvouch3 = '1';
}
echo "$qvouch3";
?>