|
|
|
ทำระบบการซื้อขายสินค้าแล้วต้องตัดจำนวนสต๊อกต้องตัดยังไงคะ |
|
|
|
|
|
|
|
ตอนบันทึกรายการขาย ให้ไปอัพเดตฐานข้อมูลครับ
สมมุติน่ะครับ
"update stock set remain = remain - $saleamount where product_id = '$productID' "
|
|
|
|
|
Date :
2014-02-18 23:11:09 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
$ps_id = $_REQUEST["ps_id"];
$ps_date = $_REQUEST["ps_date"];
$pro_id = $_REQUEST["ps_name"];
$ps_total = $_REQUEST["ps_total"];
$ps_price = $_REQUEST["ps_price"];
$sal_id = $_REQUEST["sal_id"];
?>
<?php
include("config.php");
$sql="INSERT INTO product_sale(ps_id,ps_date,ps_name,ps_total,ps_price,sal_id)";
$sql.="VALUES('','$ps_date','$ps_name','$ps_total','$ps_price','$sal_id')";
$result = mysql_query($sql,$conn)
or die("äÁèÊÒÁÒöà¾ÔèÁ¢éÍÁÙÅŧµÒÃÒ§ product_sale ä´é".mysql_error());
//insert
echo "การขายเสร็จสมบูรณ์";
$sql ="select * from product";
$sql.="where pro_id='$pro_id'";
$dbquery=mysql_query($sql,$conn) or die ("sql ???????");
$num_rows=mysql_num_rows($dbquery);
$data=mysql_fetch_array($dbquery);
$ps_total=$data["ps_total"];
$pro_tproduct=$data["pro_tproduc"];
$product=$pro_tproduct-$ps_total;
$sql="update product set pro_tproduct = pro_tproduct - $ps_total where pro_id = '$pro_id' ";
$sql.="where pro_id='$pro_id'";
mysql_query($sql,$conn)
or die("????????????") .mysql_error();
mysql_close($conn);
echo "<meta http-equiv=\"refresh\"content=\"5;URL=product_sales.php\">";
?>
</head>
<body>
<script language="JavaScript">
document.location.href="product_sales.php";
</script>
</body>
</html>
|
|
|
|
|
Date :
2014-02-18 23:30:31 |
By :
rattanaporn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยสมัครสมาชิกด้วยน่ะครับ
|
|
|
|
|
Date :
2014-02-18 23:35:43 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|