|
|
|
มีคำถามครับพี่ครับมีขอสงสัยครับคือจาก PHP สร้างระบบตะกร้าสั่งซื้อสินค้า Shopping Cart ด้วย Session และ Array (PHP กับ MySQL) กระทู้นี้ |
|
|
|
|
|
|
|
ขอดูโค๊ดของคุณครับ
|
|
|
|
|
Date :
2013-05-02 15:33:01 |
By :
Ex-[S]i[L]e[N]t |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คือของผมเอามาเขียนต่อจากกระทู้นั้นอ่ะครับ
อันนี้โค้ดผมที่เขียนเพิ่มแต่อาร์เรย์ไม่เข้าคือผมเพิ่มชื่อสินค้าลงไปแต่ไม่เข้าแต่นอกนั้นเข้า
Code (PHP)
<?php require_once('Connections/config.php'); ?><?php
session_start();
require_once('Connections/config.php'); ?>
<?
for($i=0;$i<=(int)$_SESSION["intLine"];$i++)
{
if($_SESSION["strProductID"][$i] != "")
{
?>
<?php
mysql_select_db($database_config, $config);
$query_order = "SELECT * FROM tbproducts WHERE Products_Id = '".$_SESSION["strProductID"][$i]."' ";
$order = mysql_query($query_order, $config) or die(mysql_error());
$row_order = mysql_fetch_array($order);
?>
<?
$productname=$row_order['Products_Name'];
$unitname=$row_order['Unit_Name'];
$productprice=$row_order['Products_Prie'];
?>
<?
$Cus_Name=$row_custo['Cus_Name'];
$Cus_add=$row_custo['Cus_add'];
$numbertotal=number_format($Total,2);
?>
<?php
$colname_custo = "-1";
if (isset($_SESSION['name'])) {
$colname_custo = (get_magic_quotes_gpc()) ? $_SESSION['name'] : addslashes($_SESSION['name']);
}
mysql_select_db($database_config, $config);
$query_custo = sprintf("SELECT * FROM tbcustomers WHERE Cus_id = %s", $colname_custo);
$custo = mysql_query($query_custo, $config) or die(mysql_error());
$row_custo = mysql_fetch_assoc($custo);
$totalRows_custo = mysql_num_rows($custo);
for($i=0;$i<=(int)$_SESSION["intLine"];$i++)
{
if($_SESSION["strProductID"][$i] != "")
{
mysql_select_db($database_config, $config);
$query_product = "SELECT * FROM tbproducts WHERE Products_Id = '".$_SESSION["strProductID"][$i]."' ";
$product = mysql_query($query_product, $config) or die(mysql_error());
$row_product=mysql_fetch_array($product );
}}
$Total = 0;
$SumTotal = 0;
for($i=0;$i<=(int)$_SESSION["intLine"];$i++)
{
if($_SESSION["strProductID"][$i] != "")
{
mysql_select_db($database_config, $config);
$query_Recordset1 = ("insert into tbdocumentspaid set Documentpaid_Type='$_GET[Documentpaid_Type2]',Documentpaid_No='$_GET[Documentpaid_No2]',Documentpaid_Day='$_GET[Documentpaid_Day]',Documentpaid_REF='$_GET[Documentpaid_REF2]',Documentpaid_Type_vat='$_GET[Documentpaid_Type_vat]',Documentpaid_Date='$_GET[Documentpaid_Date]',Dis_Id='$_SESSION[cusname]',Cus_Name='$Cus_Name',Cus_add='$Cus_add',Products_Id=".$_SESSION["strProductID"][$i].",Products_Name='$productname',Unit_Name='$unitname',Documentpaid_Num=".$_SESSION["strQty"][$i].",Documentpaid_Price='$productprice',Documentpaid_Discount='$_GET[Documentpaid_Discount]',Documentpaid_Amount='$numbertotal',Documentpaid_Documentpaid_Discount_Vat='$_GET[Documentpaid_Documentpaid_Discount_Vat]',Documentpaid_add_Discount='$_GET[Documentpaid_add_Discount]',Documentpaid_total='$_SESSION[sumtotal]',Documentpaid_Discount_add_dex='$_SESSION[var_vat]',Documentpaid_Units='$_SESSION[var_net]'");
$Recordset1 = mysql_query($query_Recordset1, $config) or die(mysql_error());
} }
?>
<? }}?>
<script>
alert("ทำการบันทึกข้อมูลเสร็จสิ้น");
window.location="order_document.php";
</script>
<!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=windows-874" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
<?php
mysql_free_result($custo);
?>
|
|
|
|
|
Date :
2013-05-02 15:47:16 |
By :
aswin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|