<? session_start(); if ( $book_title != "" ) { if ( session_is_registered( "ses_basket_items" ) )//มีของในตะกร้าก่อนหน้านี้ {//ถ้ามี $basket_position_counter = 0; $double = 0; // echo"\n$ses_basket_items รายการ"; if ( $ses_basket_items > 0 ) { foreach ( $ses_basket_name as $basket_item )//ดึงค่าของซ้ายมาใส่ในตัวแปรbasket_item { if ( $basket_item == $book_title ) // =ของที่จะซื้อ ซ้ำกับที่มัในตะกร้าหรือเปล่า {//ถ้าซ้ำ $double = 1; $basket_position = $basket_position_counter; } // echo"<br>$basket_position_counter";//ดูค่าตัวแปร $basket_position_counter++;//ตำแหน่งใน array // echo"<br>$basket_position_counter";//ดูค่าตัวแปร } } if ( $double == 1 )//กรณีชื่อสินค้าซ้ำ { $ses_basket_amount[$basket_position] = $quantity; echo "<meta http-equiv=\"refresh\" content=\"0;URL=".$_SERVER['PHP_SELF']."\" />"; } else //กรณีชื่อสินค้าไม่ซ้ำ { $ses_basket_name[] = $book_title; $ses_basket_amount[] = 1; $ses_basket_price[] = $book_price; $ses_basket_id[] = $book_id; $ses_basket_pic[] = $book_pic; $ses_basket_items++; echo "<meta http-equiv=\"refresh\" content=\"0;URL=".$_SERVER['PHP_SELF']."\" />"; } } //ถ้ายังไมีมีของในตะกร้า else { $ses_basket_items = 1; $ses_basket_name[0] = $book_title; $ses_basket_amount[0] = 1; $ses_basket_price[0] = $book_price; $ses_basket_id[0] = $book_id; $ses_basket_pic[0] = $book_pic; session_register( "ses_basket_items" ); session_register( "ses_basket_name" ); session_register( "ses_basket_amount" ); session_register( "ses_basket_price" ); session_register( "ses_basket_id" ); session_register( "ses_basket_pic" ); echo "<meta http-equiv=\"refresh\" content=\"0;URL=cart.php\" />"; } }//จบการนำของใส่ตะกร้า ?> <!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>test by tkapai</title> <script type="text/javascript"> var GB_ROOT_DIR = "./greybox/"; </script> <script type="text/javascript" src="greybox/AJS.js"></script> <script type="text/javascript" src="greybox/AJS_fx.js"></script> <script type="text/javascript" src="greybox/gb_scripts.js"></script> <link href="greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all" /> <link href="style.css" rel="stylesheet" type="text/css" /> <script language="javascript"> function tchk(form){ if(form.muser.value==""){ alert('Please input Username'); form.muser.focus(); return false; } if(form.mpass.value==""){ alert('Input you Password'); form.mpass.focus(); return false; } return true; } function frmchk(form){ if(form.firstName.value==""){ alert('Input your Name'); form.firstName.focus(); return false; } if(form.lastName.value==""){ alert('Input your Last Name'); form.lastName.focus(); return false; } if ((form.myEmail.value == "") || (form.myEmail.value.indexOf('@') == -1) || (form.myEmail.value.indexOf('.') == -1)) { alert("Invalid Your Email Address"); return false; } if(form.password.value==""){ alert('Input your Password'); form.password.focus(); return false; } if(form.pconfirm.value==""){ alert('Input Confirm Password'); form.pconfirm.focus(); return false; } if(form.password.value!=form.pconfirm.value){ alert('Confirm Password != Password'); form.password.focus(); return false; } if(form.phoneNo.value==""){ alert('Input Phone Number'); form.phoneNo.focus(); return false; } if(form.mobile.value==""){ alert('Input Mobile Phone'); form.mobile.focus(); return false; } if(form.address.value==""){ alert('Input your Address'); form.address.focus(); return false; } if(form.city.value==""){ alert('Input City'); form.city.focus(); return false; } if(form.state.value==""){ alert('Input State'); form.state.focus(); return false; } if(form.postCode.value==""){ alert('Input Postcode'); form.postCode.focus(); return false; } if(form.country.value==""){ alert('Select your Country'); form.country.focus(); return false; } return true; } </script> <script type="text/javascript" src="jquery-1.2.2.pack.js"></script> <script type="text/javascript" src="ajaxtooltip.js"></script> </head> <body> <table width="88%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="13%" align="center" style="padding-bottom:5px;">Product Name</td> <td width="14%" align="center" style="padding-bottom:5px;">Quantity</td> <td width="13%" align="center" style="padding-bottom:5px;">Price</td> <td width="14%" align="center" style="padding-bottom:5px;">Edit</td> <td width="17%" align="center" style="padding-bottom:5px;">Total</td> <td width="16%" style="padding-bottom:5px;"> </td> </tr> <? $swap = "2"; $total = 0; $i=0; for ( $basket_counter=0; $basket_counter<$ses_basket_items; $basket_counter++ ) { $book_price = $ses_basket_price[$basket_counter]; $quantity = $ses_basket_amount[$basket_counter]; $book_title = $ses_basket_name[$basket_counter]; $book_id = $ses_basket_id[$basket_counter]; $book_pic= $ses_basket_pic[$basket_counter]; if ( $swap == "1" ) { $color = "#FFFFFF"; $swap = "2"; } else { $color = "#dddddd"; $swap = "1"; } if ($quantity !=0) //ถ้าของในตะกร้ามีจำนวนเป็น 0 จะไม่แสดงรายละเอียดสินค้าออกมา { $amount = $quantity*$book_price; $total += $amount; $i++; ?> <script language="JavaScript" type="text/javascript"> function Conf(object) { if (confirm("Are you sure you want to Remove ?") == true) { return true; } return false; } function Uconf(object) { if (confirm("Are you sure you want to Update ?") == true) { return true; } return false; } </script> <form id="form1" name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>" onsubmit="return Uconf(this);"> <input type="hidden" name="book_id" value="<?=$book_id?>" /> <input type="hidden" name="book_title" value="<?=$book_title?>" /> <tr> <td height="1" colspan="6" bgcolor="#CCCCCC"></td> </tr> <tr> <td align="center" style="padding-top:5px; padding-bottom:5px;"><?=$book_title?></td> <td align="center" style="padding-top:5px; padding-bottom:5px;"><input name="quantity" type="text" id="quantity" style="text-align:center" value="<?=$quantity?>" size="3" maxlength="3"/></td> <td align="center" style="padding-top:5px; padding-bottom:5px;"><?=number_format($book_price,0)?> $</td> <td align="center" style="padding-top:5px; padding-bottom:5px;"><a href='cart.php?book_id=<?=$book_id?>&book_title=<?=$book_title?>&quantity=0&act=remove' onclick="return Conf(this);"> </a> <div align="center"><a href="cart.php?book_id=<?=$book_id?>&book_title=<?=$book_title?>&quantity=0&act=remove" onclick="return Conf(this);"><span style="text-decoration: underline;">remove</span></a></div> <a href="cart.php?book_id=<?=$book_id?>&book_title=<?=$book_title?>&quantity=0&act=remove" onclick="return Conf(this);"></a></td> <td align="center" style="padding-top:5px; padding-bottom:5px;"><?=number_format($amount,0)?> $</td> <td align="right" style="padding-top:5px; padding-bottom:5px;"><input type="submit" name="button" id="button" value="Update" /></td> </tr> </form> <? } } $_SESSION['tamount']=$total; $_SESSION['item']=$i; ?> <tr> <td height="1" colspan="6" bgcolor="#CCCCCC"></td> </tr> <tr> <td colspan="6" align="right" style="padding-top:5px; padding-bottom:5px;"><strong>Subtotal :</strong> <?=number_format($total,0)?> $</td> </tr> <tr> <td colspan="6" align="right" style="padding-top:5px; padding-bottom:5px;"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="82%" align="right"><input type="button" name="button2" id="button2" value="Continue shop" style="cursor:pointer;" onclick="window.location='index.php'" /></td> <td width="18%" align="right"><input type="button" name="button3" id="button3" value="Check Out" /></td> </tr> </table></td> </tr> </table> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง