รายละเอียดของการตอบ ::
<?
session_start();
include('config.inc.php');
session_register("cart");
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?
include("config.inc.php");
$strSQL = "INSERT INTO bill ";
$strSQL .="(Price,P_Number2,ID_User,ID_Product) ";
$strSQL .="VALUES ";
$strSQL .="('".$_SESSION['total']."','".$_SESSION['qty']."','".$_SESSION["ID_User"]."','".$_SESSION["ID_Product"]."') ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
include("config.inc.php");
$total=0;
echo '<pre>', print_r($_SESSION['cart'], true), '</pre>';
foreach($_SESSION['cart'] as $_SESSION['ID_Product']=>$_SESSION['qty'])
{
$sql = "SELECT * FROM product where ID_Product = '".$_SESSION['ID_Product']."' ";
$query = mysql_query($sql) or die ("error=$sql");
$objResult = mysql_fetch_array($query);
$_SESSION['P_Price'] = $objResult['P_Price'];
$sum = $_SESSION['P_Price']*$_SESSION['qty'];
$_SESSION['total'] += $sum;
$strSQL = "Update product Set P_Number = P_Number - '".$_SESSION['qty']."' WHERE ID_Product = '".$_SESSION['ID_Product']."' ";
$objQuery = mysql_query($strSQL);
mysql_close();
}
}
?>
echo "<script language=\"JavaScript\" type=\"text/JavaScript\">alert('แก้ไขข้อมูลเรียบร้อยแล้วค่ะ') </script> ";
echo"<meta http-equiv='refresh' content='0;url=user_page.php?id=2'>";
exit();