<?php
for($i=0;$i<$row;$i++){
	$pm_autoid 		= $_POST["pm_autoid".$i];
	$qty 			= $_POST["qty".$i];
	$price 			= $_POST['pm_bprice'.$i];
	$subtotal  		= $_POST['subtotal'.$i];
	$nett_price  	= $_POST['nett_price'.$i];
	$pm_disc  		= $_POST['pm_disc'.$i];
	$pm_disctype  	= $_POST['pm_disctype'.$i];
	$expdate 		= dtosql($_POST['expdate'.$i]);
	$ums 			= $_POST['um'.$i];
	
	if($qty!=0){
		$sqlprod = "SELECT * FROM mst_product
		WHERE pm_autoid = '$pm_autoid' LIMIT 0,1";
		$prod_conn = $conn->query($sqlprod);
		$prod = $prod_conn->fetch_assoc();
		$prod_name = $conn->real_escape_string($prod['pm_name']);

		$sqlin = "INSERT INTO podetail 
			(po_autoid,pm_autoid,pm_name,pod_qty,pod_price,pod_ums,pod_subtotal,pod_nett_price,pod_disc,pod_disctype,pod_expdate) 
			VALUES 
			('$autoid','$pm_autoid','$prod_name','$qty','$price','$ums','$subtotal','$nett_price','$pm_disc','$pm_disctype','$expdate')";
			if($prod_name){
				$conn->query($sqlin) or die($sqlin);
			}

	}
}
?>