<?php //session_start(); //session_destroy(); ?><html> <head> <title>ThaiCreate.Com</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <?php mysql_connect("localhost","root","root"); mysql_select_db("mydatabase"); $strSQL = "SELECT * FROM product"; $objQuery = mysql_query($strSQL) or die(mysql_error()); ?> <table width="450" border="1"> <tr> <td width="101">Picture</td> <td width="101">ProductID</td> <td width="82">ProductName</td> <td width="50">Price</td> <td width="100">Cart</td> </tr> <?php while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <form action="order.php" method="post"> <td><img src="img/<?php echo $objResult["Picture"];?>"></td> <td><?php echo $objResult["ProductID"];?></td> <td><?php echo $objResult["ProductName"];?></td> <td><?php echo $objResult["Price"];?></td> <td><input type="hidden" name="txtProductID" value="<?php echo $objResult["ProductID"];?>" size="2"> <input type="text" name="txtQty" value="1" size="2"> <input type="submit" value="Add"></td> </form> </tr> <?php } ?> </table> <br><br><a href="show.php">View Cart</a> | <a href="clear.php">Clear Cart</a> <?php mysql_close(); ?> </body> </html> <?php /* This code download from www.ThaiCreate.Com */ ?>
<?php ob_start(); session_start(); if(!isset($_SESSION["intLine"])) { if(isset($_POST["txtProductID"])) { $_SESSION["intLine"] = 0; $_SESSION["strProductID"][0] = $_POST["txtProductID"]; $_SESSION["strQty"][0] = $_POST["txtQty"]; header("location:show.php"); } } else { $key = array_search($_POST["txtProductID"], $_SESSION["strProductID"]); if((string)$key != "") { $_SESSION["strQty"][$key] = $_SESSION["strQty"][$key] + $_POST["txtQty"]; } else { $_SESSION["intLine"] = $_SESSION["intLine"] + 1; $intNewLine = $_SESSION["intLine"]; $_SESSION["strProductID"][$intNewLine] = $_POST["txtProductID"]; $_SESSION["strQty"][$intNewLine] = $_POST["txtQty"]; } header("location:show.php"); } ?> <?php /* This code download from www.ThaiCreate.Com */ ?>
<?php session_start(); ?> <html> <head> <title>ThaiCreate.Com</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <?php mysql_connect("localhost","root","root"); mysql_select_db("mydatabase"); ?> <form action="update.php" method="post"> <table width="400" border="1"> <tr> <td width="101">ProductID</td> <td width="82">ProductName</td> <td width="82">Price</td> <td width="79">Qty</td> <td width="79">Total</td> <td width="10">Del</td> </tr> <?php $Total = 0; $SumTotal = 0; for($i=0;$i<=(int)$_SESSION["intLine"];$i++) { if($_SESSION["strProductID"][$i] != "") { $strSQL = "SELECT * FROM product WHERE ProductID = '".$_SESSION["strProductID"][$i]."' "; $objQuery = mysql_query($strSQL) or die(mysql_error()); $objResult = mysql_fetch_array($objQuery); $Total = $_SESSION["strQty"][$i] * $objResult["Price"]; $SumTotal = $SumTotal + $Total; ?> <tr> <td><?php echo $_SESSION["strProductID"][$i];?><input type="hidden" name="txtProductID<?php echo $i;?>" value="<?php echo $_SESSION["strProductID"][$i];?>"></td> <td><?php echo $objResult["ProductName"];?></td> <td><?php echo $objResult["Price"];?></td> <td><input type="text" name="txtQty<?php echo $i;?>" value="<?php echo $_SESSION["strQty"][$i];?>" size="2"></td> <td><?php echo number_format($Total,2);?></td> <td><a href="delete.php?Line=<?php echo $i;?>">x</a></td> </tr> <?php } } ?> </table> <table width="400" border="0"> <tr> <td><input type="submit" value="Update"></td> <td align="right">Sum Total <?php echo number_format($SumTotal,2);?></td> </tr> </table> </form> <br><br><a href="product.php">Go to Product</a> <?php if($SumTotal > 0) { ?> | <a href="checkout.php">CheckOut</a> <?php } ?> <?php mysql_close(); ?> </body> </html> <?php /* This code download from www.ThaiCreate.Com */ ?>
<?php ob_start(); session_start(); for($i=0;$i<=(int)$_SESSION["intLine"];$i++) { if($_SESSION["strProductID"][$i] != "") { $_SESSION["strQty"][$i] = $_POST["txtQty".$i]; } } header("location:show.php"); ?> <?php /* This code download from www.ThaiCreate.Com */ ?>