<?php
if ($addflag != 1) {

//---------------------------------------
    $chkqry = mysql_query("SELECT $keyfld FROM `$maindb` WHERE $keyfld < '$qvouch' ORDER BY $keyfld DESC LIMIT 0,1") or die(mysql_error());
    $chkcode = mysql_fetch_object($chkqry);
    $prevvouch = $chkcode->$keyfld;

    $pdisabled1 = '';
    if ($prevvouch == '') {
        $pdisabled1 = 'disabled';
    }

    $chkqryn = mysql_query("SELECT $keyfld FROM `$maindb` WHERE $keyfld > '$qvouch' ORDER BY $keyfld LIMIT 0,1") or die(mysql_error());
    $chkcoden = mysql_fetch_object($chkqryn);
    $nextvouch = $chkcoden->$keyfld;

    $ndisabled1 = '';
    if ($nextvouch == '') {
        $ndisabled1 = 'disabled';
    }
}
?>