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

$acode = $group.$type;

$result = mysqli_query($conn,"select max(acctcode) from acctgroup where substring(acctcode,1,4) = '$acode' ") or die(mysqli_error());
$row = mysqli_fetch_row($result);
if($row[0]>0)
{
	$newcode = $row[0]+1;
}
else
{
	$newcode = $acode.'0001';
}

$query="insert into acctgroup values ('$newcode','$headname','$group','$type','$groupthis',NULL)";
mysqli_query($conn,$query) or die(mysqli_error());
?>
 <meta http-equiv="refresh" content="0 url=input.php">
