2016-03-03 66 views
0
$sql = "INSERT INTO stock (Date, Description, Product_Code, DEO, Cartons, Items, Quantity, Sent_To) VALUES ('$date','$description', '$productcode','$deo', '$cartons', '$items', '$quantity', '$sent_to')"; 
    //$sql1 = "SELECT * FROM stockcount WHERE Product_Code = '".$productCode."'; 
    //$sql1 = mysqli_query("UPDATE stockcount SET Quantity='" . Quantity-$quantity . "' WHERE Product_Code='$productcode'"); 


    if ($conn->query($sql)===TRUE) { 

     header("Location:sendorder.php"); 

    } 
    else { 

     echo "Error is " .$sql."<br>". $conn->error; 
    } 

$ sql插入日期,說明,產品代碼,deo,紙盒,項目,數量併發送到庫存表。 product_code是庫存表中的外鍵,並通過下拉菜單插入。我想通過產品代碼找到stockcout表中的產品,並通過$ sql插入的數量減少其數量。請幫助我生成一個查詢,可以通過庫存盤點表中的product_code更新數量。我嘗試了一些查詢,我評論過,請檢查這些。 You can see both the stock and stockcount table here。如果你能幫助我,我會很高興。在此先感謝當銷售表數量增加時,數量可用列應自動減少

+0

您使用的是MySQL還是SQL Server?它對答案有所不同。請刪除不正確的標籤。 –

回答