<?php
session_start();
include 'dbc.php';



$userid=$_SESSION["userid"];

$size = count($_POST['saleqty']);

$i = 0;
while ($i < $size) {
	$saleqty= $_POST['saleqty'][$i];
	
	$id = $_POST['id'][$i];
	$inv_no= $_POST['inv_no'][$i];
	
	$item_name= $_POST['item_name'][$i];
	$srate= $_POST['srate'][$i];
	$inv_no= $_POST['inv_no'][$i];
	


	$netamount=$saleqty * $srate;
	
 	
	$sql1 = "UPDATE complain_details SET srate='$srate',qty='$saleqty' WHERE id='$id'";
$conn->query($sql1);

$tnetamount = $tnetamount + $srate;
	
	++$i;
$sql2 = "UPDATE complain SET netamount='$tnetamount' WHERE id='$inv_no'";
$conn->query($sql2);
// do the update and print out some info just to provide some visual feedback



} 
header("location:Open_Complains.php");

?>
