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

$std_id = $_POST['mystdId'];
$prod_id = $_POST['myprodId'];
$spec = $_POST['mystd'];
$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 standard SET SpecId = '$spec[$i]',
										CL = '$cl[$i]',
										Allowance = '$allowance[$i]'
									WHERE StdID = '$std_id[$i]'";

			mysqli_query($koneksi, $query)
			or die ("Gagal Perintah SQL".mysql_error());
	} else {
    $query = "insert INTO standard SET
										ProductId = '$prod_id[$i]',
										SpecId = '$spec[$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');

?>

