<?php include("../../include/dbconnect.php");

$result = mysqli_query($conn,"select max(acctcode) from acctmast where acctgroup = '$accthead' order by acctcode ") or die(mysqli_error());
$row = mysqli_fetch_row($result);
 $newcode=$row[0];
 if(empty($newcode))
   { 
   	$newcode=$accthead.'0001'; 
	}
 else
 { 
 	$newcode=$newcode+1; 
 } 


if ($submit == "Submit")
{
	if (!empty($description))
	{
		$query="insert into acctmast values ('$newcode','$description','$accthead','$type','Yes','','$opening_balance','$db_cr','',NULL)";
		mysqli_query($conn,$query) or die(mysqli_error());
	}
}

?>
<meta http-equiv="refresh" content="0 url=input.php">

