<?php
include "../koneksi.php";

$std_id = $_POST['mystdId'];
$prod_id = $_POST['myprodId'];
$spec = $_POST['mystd'];
$type_cek = $_POST['mytypecek'];
$cl = $_POST['mycl'];
$allowance = $_POST['myalw'];

$hitung = count($std_id);

for( $i=0; $i < $hitung; $i++ ) {
	if($prod_id[$i]!==''&&$spec[$i]!=='') {
		if($std_id[$i]!=='') {
			$query = "UPDATE add_std SET SpecId = '$spec[$i]',
											Type_Cek = '$type_cek[$i]',
											CL = '$cl[$i]',
											Allowance = '$allowance[$i]'
										WHERE AddStdID = '$std_id[$i]'";
	
				mysqli_query($koneksi, $query)
				or die ("Gagal Perintah SQL".mysql_error());
	} else {
    $query = "insert INTO add_std SET
										ProductId = '$prod_id[$i]',
										SpecId = '$spec[$i]',
										Type_Cek = '$type_cek[$i]',
										CL = '$cl[$i]',
										Allowance = '$allowance[$i]'
										";

	mysqli_query($koneksi, $query)
	or die ("Gagal Perintah SQL".mysql_error());
	}
} else {

}
}

header('Location:../index.php?switch=product');

?>

