|
 |
|
สอบถามคะ ถ้าจะเก็บค่าหน่วยของสินค้าเช่น ถุง กิโลกลัม ลงในตาราง Order Detial |
|
 |
|
|
 |
 |
|
ในตาราง Order Detail ต้องการที่จะเก็บหน่วยของสินค้าด้วยอะค่ะ แต่ลองเขียนดูแล้วปรากฏว่าข้อมูลมันไม่เข้าตาราง Order detail เลยอค่ะ
show
for($i=0;$i<=(int)$_SESSION["intLine"];$i++)
{
if($_SESSION["strid_product"][$i] != "")
{
$strSQL = "SELECT * FROM product Inner JOIN unit on product.id_unit = unit.id_unit WHERE id_product = '".$_SESSION["strid_product"][$i]."' ";
$objQuery = mysqli_query($objCon,$strSQL);
$objResult = $objResult = mysqli_fetch_array($objQuery,MYSQLI_ASSOC);
$Total = $_SESSION["strQty"][$i] * $objResult["price"];
$SumTotal = $SumTotal + $Total;
?>
<tr>
<td><h3><?php echo $_SESSION["strid_product"][$i];?></h3></td>
<td><h3><?php echo $objResult["product"];?></h3></td>
<td><h3><?php echo $_SESSION["strid_unit"][$i];?></h3></td>
<td><h3><?php echo $objResult["price"];?></h3></td>
<td><h3><input type="text" name="Qty<?php echo $i;?>" value="<?php echo $_SESSION["strQty"][$i];?>" size="3" onKeyUp="chk()"></h3></td>
<td><h3><?=number_format($Total,2);?></h3></td>
<td><a href="delete.php?Line=<?=$i;?>"><h3>ลบ x</h3></a></td>
</tr>
<?php
}
}
?>
save/head]
$strSQL2 = "INSERT INTO trans (datetime,name,address,date) VALUES ('".date("Y-m-d H:i:s")."','".$_POST["name"]."','".$_POST["address"]."' ,'".$_POST["date"]."') ";
$objQuery = mysqli_query($objCon,$strSQL2);
$strOrderID = mysqli_insert_id($objCon);
for($i=0;$i<=(int)$_SESSION["intLine"];$i++)
{
if($_SESSION["strid_product"][$i] != "")
{
$strSQL = "INSERT INTO order_detial (id_order,id_product,Qty) VALUES ('".$strOrderID."','".$_SESSION["strid_product"][$i]."','".$_SESSION["strid_unit"][$i]."','".$_SESSION["strQty"][$i]."') ";
mysqli_query($objCon,$strSQL);
}
}
[head]Code (PHP)
<?php
ob_start();
session_start();
if(!isset($_SESSION["intLine"]))
{
$_SESSION["intLine"] = 0;
$_SESSION["strid_product"][0] = $_GET["ProductID"];
$_SESSION["strid_unit"][0] = $_GET["UnitID"];
$_SESSION["strQty"][0] = 1;
header("location:show.php");
}
else
{
$key = array_search($_GET["ProductID"], $_SESSION["strid_product"]);
if((string)$key != "")
{
$_SESSION["strQty"][$key] = $_SESSION["strQty"][$key] + 1;
}
else
{
$_SESSION["intLine"] = $_SESSION["intLine"] + 1;
$intNewLine = $_SESSION["intLine"];
$_SESSION["strid_product"][$intNewLine] = $_GET["ProductID"];
$_SESSION["strid_unit"][0] = $_GET["UnitID"];
$_SESSION["strQty"][$intNewLine] = 1;
}
header("location:show.php");
}
?>
Tag : PHP, MySQL

|
ประวัติการแก้ไข 2016-03-10 04:05:29
|
 |
 |
 |
 |
Date :
2016-03-10 03:36:44 |
By :
mineymin |
View :
780 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
save/head
11.$strSQL = "INSERT INTO order_detial
(id_order,id_product,Qty)
VALUES
('".$strOrderID."','".$_SESSION["strid_product"][$i]."',
'".$_SESSION["strid_unit"][$i]."','".$_SESSION["strQty"][$i]."') ";
12.mysqli_query($objCon,$strSQL) or die(mysqli_error($objCon)."<br>$strSQL");
กำหนด field ไว้ 3 แต่ values มี4
และสีน้ำตาล หัดใส่บ้างเวลาเออเร่อร์จะได้รู้ว่าอะไร
|
 |
 |
 |
 |
Date :
2016-03-10 08:18:11 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|