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

$result = mysqli_query($conn,"select max(prodcode) from product where catcode = '$prodcat' ") or die(mysqli_error());
$row = mysqli_fetch_row($result);
 $newcode=$row[0];
 if(empty($newcode))
   { 
   	$newcode=$prodcat.'0001'; 
	}
 else
 { 
 	$newcode=$newcode+1; 
 } 


if ($submit == "Submit")
{
	if (!empty($prodname))
	{
	
		if($stprodcode == 'Same')
		{
			$stp = $newcode;
		}
		else
		{
			$stp = $stprodcode;
		}
		

		$query="insert into product values ('$newcode','$prodname','$prodcat','$packed','$capacity','$weight','$minimum_qty','Yes','$acct_record','$rate','$stp','$tax_rate',NULL)";
		mysqli_query($conn,$query) or die(mysqli_error());
	}
}

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

