<?php session_start(); //Create 'cart' if it doesn't already exist if (!isset($_SESSION['SHOPPING_CART'])){ $_SESSION['SHOPPING_CART'] = array(); } //Add an item only if we have the threee required pices of information: name, price, qty if (isset($_POST['add']) && isset($_POST['price']) && isset($_POST['qty'])){ //Adding an Item //Store it in a Array $ITEM = array( //Product id 'product_id' => $_POST['product_id'], //Item Price 'price' => $_POST['price'], //Qty wanted of item 'qty' => $_POST['qty'] ); //Add this item to the shopping cart $_SESSION['SHOPPING_CART'][] = $ITEM; //Clear the URL variables header('Location: ' . $_SERVER['PHP_SELF']); } for($a=1 ; $a<=$_POST['loop']; $a++){ foreach ( $_SESSION['SHOPPING_CART'] as $key => $value ) { /* echo $key . " = " . $value . "<BR/>";*/ echo $a."<br />"; echo "product_id = ".$product_id."<br />"; echo "qty = ".$qty."<br />"; echo "price = ".$price."<br />"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="post" action=""> <table width="250" border="0" cellspacing="0" cellpadding="0"> <tr> <td> </td> <td> <? for($a=0 ; $a<=5; $a++){ ?> <input type="hidden" name="loop" value="<?=$a?>" /> <input type="hidden" name="product_id" value="<?=$a+5?>" /> <input type="hidden" name="qty" value="1" /> <input type="hidden" name="price" value="3,500" /> <input type="submit" name="Submit" value="Submit" /> <? } ?> </td> </tr> </table> </form> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง