<? session_start(); ob_start(); require_once"config.inc.php"; require_once('top.inc.php'); require_once('function.inc.php'); //Check ว่ามีซ้ำแล้วหรือยัง if($_GET["NO"] != ""){ for($i=0;$i<=count($_SESSION["strProductNO"]);$i++){ if($_SESSION["strProductNO"][$i] == $_GET["NO"]){ header("location:$_SERVER[PHP_SELF]"); exit(); } } } //ถ้ามีการเลือกรายการสินค้าให้เก็บลง Session if(trim($_GET["NO"]) != ""){ $_SESSION["strP"]=$_SESSION["strP"]+1; $_SESSION["strProductNO"][$_SESSION[strP]]=$_GET["NO"]; $_SESSION["strQuanlity"][$_SESSION[strP]]=1; session_write_close(); header("location:$_SERVER[PHP_SELF]"); } ?> <form action="" method="post" name="frmCart" id="frmCart"> <table width="650" height="21" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666"> <tr bgcolor="#FFFFFF" align="center"> <td><div id="font"> No.</div></td> <td><div id="font">Items</div></td> <td><div id="font">Price/Unit</div></td> <td><div id="font">Transport fee</div></td> <td><div id="font">Quantity</div></td> <td><div id="font">Total Price</div></td> <td><div id="font">Delete</div></td> </tr> <tr bgcolor="#FFFFFF"> <td> //เอาโค้ดมาวางตรงนี้แล้วตารางมันขาดครับ <? $num=0; $totalnum=0; for($i=0;$i<count($_SESSION["strProductNO"]);$i++){ $sql_command="(select*from tb_product where NO='".$_SESSION["strProductNO"]["$i"]."')"; $result=mysql_query($sql_command) or die (mysql_error()); if($result){ $num++; ?> </td> <tr bgcolor="#FFFFFF"> <td align="center"><?=$num?></td> <td><?=$result["NAMEBOOK"];?></td> //ตรงนี้ค่าไม่ยอมตะกร้า <td><?=$result["PRICE_MEMBER"];?></td> //ตรงนี้ค่าไม่ยอมตะกร้า <td><?=$result["PRICE"];?></td> //ตรงนี้ค่าไม่ยอมตะกร้า <td><input name="txtP[]" type="hidden" id="txtP[]" value="<?=$i;?>"> <input name="txtQua[]" type="text" id="txtQua<?=$num;?>" style="width:50px;text-align:right" value="<?=$_SESSION["strQuanlity"]["$i"];?>" maxlength="3" onChange="checknum(this.value,'txtQua<?=$num;?>');"></td> <td><?="".number_format(($result["PRICE_MEMBER"]+$result["PRICE"])*$_SESSION["strQuanlity"]["$i"], 2,'.',',');?></td> <td align="center"><a href="javascript:if(confirm('Are you sure delete this item?')==true){window.location='<?=$_SERVER['PHP_SELF'];?>?action=Delete&P=<?=$i;?>';}"><img src="images/icon_delete.gif" border="0"/></a></td> </tr> </table> <? }//if }//for echo "<br>sql :".$sql_command."<br>"; echo "NAMEBOOK".$result["NAMEBOOK"]; ?> <br> <table width="650" height="21" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666"> <tr bgcolor="#FFFFFF"> <td><div align="right">Quantity (itmes)</div></td> <td> <div align="right"><?=$num;?></div></td> </tr> <tr bgcolor="#FFFFFF"> <td> <div align="right">Total Price (Baht)</div></td> <td width="16%"> <div align="right"> <?="".number_format($totalnum, 2,'.',',');?></div></td> </tr> </table> </form>
Quote:$sql_command="(select*from tb_product where NO='".$_SESSION["strProductNO"]["$i"]."')";
$sql_command="(SELECT*FROM tb_product WHERE 1=1 AND NO='".$_SESSION["strProductNo"]["$i"]."')";
$sql_command="(select*from tb_product where NO='".$_SESSION["strProductNO"]["$i"]."')"; $query=mysql_query($sql_command) or die (mysql_error()); // เปลี่ยนชื่อตัวแปรนิดจะได้ไม่ทับซ้อนกัน if($query){ $result=mysql_fetch_array($query); // ลืม fetch บรรทัดนี้ $num++;
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง