<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ThinClientNetwork : Edit Qty and Price! For Quotation!!!</title> <link rel="stylesheet" href="../cus/css/style_main.css" /> <script> function deleteCart(pid) { if(!confirm('ลบสินค้านี้ ?')) { return; } location = "<?php echo $_SERVER['PHP_SELF']; ?>?pid=" + pid; } </script> </head> <body> <?php include("menutop.php"); include("conn.inc.php"); connect_db(); $cid = $_REQUEST['cid']; ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <?php if($_POST) { foreach($_POST as $pid => $qty) { if(!is_numeric($qty) || $qty <= 0) { continue; } $cid = $_REQUEST['cid']; $sql = "UPDATE request SET qty = $qty WHERE pro_id = $pid AND cus_ord_id = '$cid';"; // $sql = "UPDATE request SET qty = $qty // WHERE pro_id = $pid AND cus_user = '$cus_user';"; @mysql_query($sql); } } else if($_GET['pid']) { $pid = $_GET['pid']; $cid = $_REQUEST['cid']; $sql = "DELETE FROM request WHERE pro_id = $pid AND cus_ord_id = '$cid';"; mysql_query($sql); } $cid = $_REQUEST['cid']; $sql = "SELECT * FROM request WHERE cus_ord_id = '$cid';"; //$sql = "SELECT * FROM request // WHERE cus_user = '$cus_user';"; $result = mysql_query($sql); if(mysql_num_rows($result) == 0) { echo "<p align=center>ไม่มีสินค้า! </p>"; echo "</form></body></html>"; exit; } ?> <table border=1 bordercolor=#cccccc cellpadding=3 align=center style="border-collapse: collapse;"> <caption>รายการสินค้าที่ลูกค้าเลือก</caption> <tr bgcolor=#ddddff> <th align=center width=220>สินค้า</th><th width=50>จำนวน</th><th width=50>ราคา</th><th width=80>รวม</th> </tr> <?php $grand_total = 0; while($cart = mysql_fetch_array($result)) { $sub_total = $cart['qty'] * $cart['price'] ; $pid = $cart['pro_id']; echo " <tr valign=top> <td> [<a href=\"javascript: deleteCart($pid)\" title=ลบรายการนี้>x</a>] {$cart['pro_name']} </td> <td align=center> <input type=text size=3 name=$pid value={$cart['qty']} /> </td> <td align=center>{$cart['price']}</td> <td align=right>$sub_total</td> </tr>"; $grand_total += $sub_total; } ?> <tr> <td colspan=3 align=center>รวมทั้งหมด</td> <td align=right><?php echo $grand_total ?></td> </tr> </table> <p align=center> <input type="button" value="« ย้อนกลับ" onclick="location='req_list.php'" /> <input type="submit" value="คำนวณใหม่" /> </p> </form> </body> </html>
//*** Update Condition ***// if($_GET["Action"] == "Save") { for($i=1;$i<=$_POST["hdnLine"];$i++) { $strSQL = "UPDATE customer SET "; $strSQL .="CustomerID = '".$_POST["txtCustomerID$i"]."' "; $strSQL .=",Name = '".$_POST["txtName$i"]."' "; $strSQL .=",Email = '".$_POST["txtEmail$i"]."' "; $strSQL .=",CountryCode = '".$_POST["txtCountryCode$i"]."' "; $strSQL .=",Budget = '".$_POST["txtBudget$i"]."' "; $strSQL .=",Used = '".$_POST["txtUsed$i"]."' "; $strSQL .="WHERE CustomerID = '".$_POST["hdnCustomerID$i"]."' "; $objQuery = mysql_query($strSQL); } //header("location:$_SERVER[PHP_SELF]"); //exit(); }
<head> <script> function deleteCart(pid) { if(!confirm('ลบสินค้านี้ ?')) { return; } location = "<?php echo $_SERVER['PHP_SELF']; ?>?pid=" + pid; } </script> </head> <body> <?php include("menutop.php"); include("conn.inc.php"); connect_db(); $cid = $_REQUEST['cid']; ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?cid=<?php echo $_REQUEST['cid']?>" method="POST"> <?php if($_POST) { foreach($_POST[pid] as $pid => $pid_val) { $sql = "UPDATE request SET qty = $qty[pid] , price = price[pid] WHERE pro_id = $pid_val AND cus_ord_id = '$cid';"; @mysql_query($sql); } } else if($_GET['pid']) { $pid = $_GET['pid']; $cid = $_REQUEST['cid']; $sql = "DELETE FROM request WHERE pro_id = $pid AND cus_ord_id = '$cid';"; mysql_query($sql); } $cid = $_REQUEST['cid']; $sql = "SELECT * FROM request WHERE cus_ord_id = '$cid';"; //$sql = "SELECT * FROM request // WHERE cus_user = '$cus_user';"; $result = mysql_query($sql); if(mysql_num_rows($result) == 0) { echo "<p align=center>ไม่มีสินค้า! </p>"; echo "</form></body></html>"; exit; } ?> <table border=1 bordercolor=#cccccc cellpadding=3 align=center style="border-collapse: collapse;"> <caption>รายการสินค้าที่ลูกค้าเลือก</caption> <tr bgcolor=#ddddff> <th align=center width=220>สินค้า</th><th width=50>จำนวน</th><th width=50>ราคา</th><th width=80>รวม</th> </tr> <?php $grand_total = 0; while($cart = mysql_fetch_array($result)) { $sub_total = $cart['qty'] * $cart['price'] ; $pid = $cart['pro_id']; echo " <tr valign=top> <td> [<a href=\"javascript: deleteCart($pid)\" title=ลบรายการนี้>x</a>] {$cart['pro_name']} </td> <td align=center> <input type=hidden size=3 name=pid[] value={$cart['qty']} /> <input type=text size=3 name=qty[] value={$cart['qty']} /> </td> <td align=center> <input type=text size=3 name=price[] value={$cart['price']} /> </td> <td align=right>$sub_total</td> </tr>"; $grand_total += $sub_total; } ?> <tr> <td colspan=3 align=center>รวมทั้งหมด</td> <td align=right><?php echo $grand_total ?></td> </tr> </table> <p align=center> <input type="button" value="« ย้อนกลับ" onclick="location='req_list.php'" /> <input type="submit" value="คำนวณใหม่" /> </p> </form> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง