<? @session_start(); @ob_start(); echo "<meta http-equiv='Content-Type' content='text/html; charset=windows-874' />"; require_once('connection.php'); $date=date("Y-m-d H:i:s"); $new_id =mysql_result(mysql_query("Select Max(substr(insert_id,-4))+1 as MaxID from tb_insertdetail"),0,"MaxID");//เลือกเอาค่า id ที่มากที่สุดในฐานข้อมูลและบวก 1 เข้าไปด้วยเลย if($new_id==""){ // ถ้าได้เป็นค่าว่าง หรือ null ก็แสดงว่ายังไม่มีข้อมูลในฐานข้อมูล $id="I0001"; }else{ $id="I".sprintf("%04d",$new_id);//ถ้าไม่ใช่ค่าว่าง } #*****************(นำเข้าข้อมูลสั่งซื้อในtb_insert)**********************# for($i=1;$i<=$id1;$i++){ if($_POST["txtproduct_id$i"] != "") { $sqlOrder="INSERT INTO tb_insert(insert_id,insert_date)VALUES('".$id."','".$date."')"; $objQuery1=mysql_query($sqlOrder) or die (mysql_error()); #*****************(นำเข้าข้อมูลรายละเอียดสั่งซื้อในtb_insertdetail)**********************# $sqlOrderView="INSERT INTO tb_insertdetail(insert_id,product_id,detail_amount) VALUES('".$id."','".$_POST["txtproduct_id$i"]."','".$_POST["after_amount$i"]."')"; $objQuery2=mysql_query($sqlOrderView) or die (mysql_error()); $rsInsOrderView=$sqlOrderView["insert_id"]; echo $sqlOrderView; #**********อัำเดตสินค้า(product_stock)***************# $sqlUpdatePd="UPDATE product_stock SET unit_product=unit_product+'".$_POST["after_amount$i"]."' WHERE product_id='".$_POST["txtproduct_id$i"]."'"; $objQuery3=mysql_query($sqlUpdatePd) or die (mysql_error()); } } ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง