|
|
|
อยากเพิ่มข้อมูลค่ะ ลองหลายวิธีแล้วไม่ได้ อยากเพิ่มข้อมูล ชื่อ ที่อยู่ และเบอร์โทร ลองหลายวิธีแล้วไม่ได้database ก็เพิ่ม |
|
|
|
|
|
|
|
อยากเพิ่มข้อมูล ชื่อ ที่อยู่ และเบอร์โทร ลองหลายวิธีแล้วไม่ได้database ก็เพิ่ม
ฟิลด์แล้วค่ะ
code
<?
session_start();
include("config.php");
include("connect.php");
mysql_query("USE $dbname");
if(!is_null($btt_Add)){
//if(($txt_Amount =="")){
//
// echo"<script language='javascript'> alert('กรุณาระบุจำนวน'); window.location='Order.php';</script> ";
// }elseif(is_numeric($txt_Amount)){
// echo"<script language='javascript'> alert('กรุณาระบุจำนวน'); window.location='Order.php';</script> ";
// }else{
session_register('ss_Order');
$ss_Order[] = array($txt_OrderID,$txt_Date,$txt_EmpID,$txt_Goods_Id,$txt_Goods,$txt_Sale,$txt_Amount,$Sum_Mon,$txt_Total);
session_register('ss_Date');
session_register('ss_EmpID'); // สำหรับนำรหัสพนักงานที่ login เข้าระบบมาแ้ล้วแสดงค่าใน text box
session_register('ss_Remark');
// }
}
if(!is_null($btt_Cal)){
session_register('ss_Discoust');
$ss_Discoust = $txt_Discount;
}
// ลบรายการสินค้าที่ไม่ต้องการ
if(!is_null($imgDel)){
session_register('ss_Order');
$tmp = NULL;
for($i =0; $i < count($ss_Order); $i++){
if($i != $imgDel){
$tmp[] = $ss_Order[$i];
}
}
$ss_Order = $tmp;
}
?>
<?
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// บันทึกข้อมูลลงฐานข้อมูล
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if(!is_null($btt_Order)){
$Order_date =date("Y-m-d");
mysql_query("BEGIN",$link);
if($txt_Discount == "") $txt_Discount = "0.0";
$sqlOrder = "INSERT INTO `tblorder`(`Order_by`,`Order_Date`,`Order_Remark`,`Discoust`,`Dis_Money`,`Total_Money`,`Order_Type`)
VALUES('$ss_EmpID','$Order_date','$ss_Remark','$txt_Discount','$Total_Discount','$Total_Summary','C')";
$result = mysql_query($sqlOrder);
// 0 1 2 3 4 5 6 7 8 9 10 11
//$ss_Order[] = array($txt_OrderID,$txt_Date,$txt_EmpID,$txt_Goods_Id,$txt_Goods,$txt_Sale,$txt_Amount,$Sum_Mon,$txt_Total);
// บันทึกรายละเอียดสินค้าลงตาราง order_detail
for($i = 0;$i<count($ss_Order);$i++){
$P_ID = $ss_Order[$i][5];
$P_Amount = $ss_Order[$i][9];
$sqlDetail = "INSERT INTO `orderdetail`(`Product_Id`,`Product_Amount`,`Order_ID`) VALUES('$P_ID','$P_Amount','$txt_ID')";
mysql_query($sqlDetail);
$CC = $CC +1;
}
if(count($ss_Order) == $CC){
mysql_query("COMMIT",$link);
session_unregister('ss_Order');
session_unregister('ss_Date');
session_unregister('ss_EmpID'); // สำหรับนำรหัสพนักงานที่ login เข้าระบบมาแ้ล้วแสดงค่าใน text box
session_unregister('ss_Remark');
session_unregister('ss_Discoust');
echo"<script language='javascript'> alert('การทำรายการเสร็จสมบูรณ์'); window.location='showAll_Order.php';</script> ";
}else{
mysql_query("ROLLBACK",$link);
session_unregister('ss_Order');
session_unregister('ss_Date');
session_unregister('ss_EmpID'); // สำหรับนำรหัสพนักงานที่ login เข้าระบบมาแ้ล้วแสดงค่าใน text box
session_unregister('ss_Remark');
session_unregister('ss_Discoust');
}
//echo $sqlOrder;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ร้านสปาร์ออนไลน์</title>
<style type="text/css">
<!--
.style1 {
color: #990000;
font-weight: bold;
}
.style2 {color: #990000}
.style5 {
color: #663300;
font-size: 14px;
}
.style8 {font-size: 14px}
.style10 {color: #0000CC}
.style12 {color: #990000; font-weight: bold; font-size: 16px; }
.style27 {color: #3333FF; font-size: 14px; font-weight: bold; }
-->
A:link{
color : #0000ff;
}
A:hover{
color:#FF0000;
background-color: #FFCC66;
}
.style29 {color: #CC3333}
.style31 {color: #CC6600}
.style33 {color: #663300}
.style35 {color: #660099}
.style37 {color: #993300}
.style42 {color: #000066}
.style44 {color: #000066; font-weight: bold; font-size: 14px; }
.style45 {font-size: 14px; color: #0000CC; }
</style>
<script language="javascript">
var newWind;
function newWindows(){
if(!newWind||newWind.close){
newWind = window.open("popgoods.php","subwindows","height = 300,width = 600,scrollbars = yes");
newWind.moveTo((screen.width/2)-200,(screen.heigth/2)-300);
}else{
newWind.focus();
}
}
function ChkAmount(){
if(isNaN(document.frm_Order.txt_Amount.value)){
alert("กรุณาระบุจำนวน");
document.frm_Order.value = "";
document.frm_Order.txt_Amount.focus();
}
}
</script>
</head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<body topmargin="0" leftmargin="0">
<div align="center"><table width="816" border="0">
<tr>
<th scope="col"><img src="image/header.gif" width="816" height="125"></th>
</tr>
</table>
<table width="820" border="0">
<tr>
<td width="482" bgcolor="#FFFF66"> </td>
<td width="163" bgcolor="#FFFF66"><div align="center"><a href="view_product.php" style="text-decoration:none">หน้าหลัก</a></div></td>
<td width="157" bgcolor="#FFFF66"><div align="center"><a href="index.php" style="text-decoration:none">ออกจากระบบ</a></div></td>
</tr>
</table><br />
<form id="frm_Order" name="frm_Order" method="post" action="">
<br />
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" bgcolor="#CCFF66"><div align="center" class="style12">สั่งซื้อสินค้า</div></td>
</tr>
<tr>
<td bgcolor="#CCFF66"> </td>
<td bgcolor="#CCFF66"> </td>
</tr>
<tr>
<td colspan="2"><div align="center">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FFCCCC"><div align="right" class="style44">เลขที่ใบสั่งซื้อ</div></td>
<td bgcolor="#FFCC66"> </td>
<td bgcolor="#FFCC66"><div align="left"><strong>
<?
session_register('ss_OrderID');
session_register('sOrderID');
$sql = "SELECT max(Order_ID) as Order_ID FROM tblorder ";
$result = mysql_query($sql) or die ("Error".mysql_error());
$fetch = mysql_fetch_array($result);
$OrderID = $fetch['Order_ID'] + 1;
//if(is_null($OrderID)){
// $Order_ID = "R0001";
// }else{
if(strlen($OrderID) == 1){
$Order_ID = "R000".$OrderID;
}elseif(strlen($OrderID)==2){
$Order_ID = "R00".$OrderID;
}elseif(strlen($OrderID)==3){
$Order_ID = "R0".$OrderID;
}elseif(strlen($OrderID)==4){
$Order_ID = "R".$OrderID;
}
//}
$ss_OrderID = $Order_ID;
$sOrderID = $OrderID;
?>
<input name="ss_OrderID" type="text" id="ss_OrderID" size="15" maxlength="15" value="<? echo $ss_OrderID; ?>" />
<input type="hidden" name="txt_ID" id="txt_ID" value="<? echo $sOrderID; ?>">
</strong></div></td>
<?
$Y_year = date('Y')+543;
$To_Day = date('d')."/".date('m')."/".$Y_year;
$ss_Date = $To_Day;
?>
<td bgcolor="#FFCC66"><div align="right" class="style44">วันที่</div></td>
<td colspan="2" bgcolor="#FFCC66"><div align="left" class="style44">
<input name="ss_Date" type="text" id="ss_Date" size="12" maxlength="12" value="<? echo $ss_Date;?>" />
</div></td>
</tr>
<tr>
<td bgcolor="#FFCCCC"><div align="right" class="style44">รหัสผู้ Order </div></td>
<td colspan="5" bgcolor="#FFCC66"><div align="left"><strong>
<input name="ss_EmpID" type="text" id="ss_EmpID" size="15" maxlength="15" value="<? echo $ss_EmpID; ?>" />
</strong></div></td>
</tr>
<tr>
<td bgcolor="#FFCCCC"><div align="right" class="style44">อื่น ๆ</div></td>
<td colspan="5" bgcolor="#FFCC66"><div align="left">
<input name="ss_Remark" type="text" id="ss_Remark" size="30" maxlength="50" value="<? echo $ss_Remark; ?>" />
</div></td>
</tr>
<tr>
<td bgcolor="#FFCCCC"><div align="right"><span class="style8"><span class="style10"><span class="style29"><span class="style31"><span class="style33"><span class="style35"><span class="style37"><span class="style42"></span></span></span></span></span></span></span></span></div></td>
<td colspan="5" bgcolor="#FFCC66"><div align="left"></div></td>
</tr>
<tr>
<td bgcolor="#FFCCCC"><div align="right" class="style44">รายการสินค้า</div></td>
<td colspan="5" bgcolor="#FFCC66"><div align="left">
<input name="txt_Goods_Id" type="text" id="txt_Goods_Id" size="5" maxlength="5" />
<input name="txt_Goods" type="text" id="txt_Goods" size="30" maxlength="50" />
<input name="btt_View" type="submit" id="btt_View" value="เลือกรายการ" onClick="newWindows();" />
</div> <div align="right"></div> <div align="left"></div></td>
</tr>
<tr>
<td bgcolor="#FFCCCC"><div align="right" class="style44">ราคาขาย</div></td>
<td bgcolor="#FFCC66"> </td>
<td bgcolor="#FFCC66"><div align="left" class="style42"><strong>
<input name="txt_Sale" type="text" id="txt_Sale" size="10" maxlength="10" />
<span class="style8">บาท</span></strong></div></td>
<td bgcolor="#FFCC66"><div align="right" class="style44">จำนวน</div></td>
<td bgcolor="#FFCC66"><div align="left" class="style44">
<input name="txt_Amount" type="text" id="txt_Amount" size="4" maxlength="4" />
ชิ้น</div></td>
<td bgcolor="#FFCC66"><div align="center" class="style5">
<input name="btt_Add" type="submit" id="btt_Add" value="เพิ่มรายการ" />
</div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><div align="center">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#99FF66"><div align="center" class="style27">ลำดับที่</div></td>
<td bgcolor="#99FF66"><div align="center" class="style27">รหัสสินค้า</div></td>
<td bgcolor="#99FF66"><div align="center" class="style27">ชื่อสินค้า</div></td>
<td bgcolor="#99FF66"><div align="center" class="style27">ราคาขาย(บาท)</div></td>
<td bgcolor="#99FF66"><div align="center" class="style27">จำนวน(ชิ้น)</div></td>
<td bgcolor="#99FF66"><div align="center" class="style27">ราคารวม(บาท)</div></td>
<td bgcolor="#99FF66"><div align="center" class="style27">ลบ</div></td>
</tr>
<?
for($i =0 ; $i < count($ss_Order) ; $i ++){
$j++;
// 0 1 2 3 4 5 6 7 8
//$ss_Order[] = array($txt_OrderID,$txt_Date,$txt_EmpID,$txt_Goods_Id,$txt_Goods,$txt_Sale,$txt_Amount,$Sum_Mon,txt_Total);
?>
<tr>
<td bgcolor="#FFFF99"><div align="center"><? echo $j; ?></div></td>
<td bgcolor="#FFFF99"><div align="center"><? echo $ss_Order[$i][3];?></div></td>
<td bgcolor="#FFFF99"><div align="left"><? echo $ss_Order[$i][4];?></div></td>
<td bgcolor="#FFFF99"><div align="right"><? echo $ss_Order[$i][5];?></div></td>
<td bgcolor="#FFFF99"><div align="right"><? echo $ss_Order[$i][6];?></div></td>
<td bgcolor="#FFFF99"><div align="right">
<?
$Sum_Mon = $ss_Order[$i][7];
$ItemAmount = $ss_Order[$i][6];
$ItemMoney = $ss_Order[$i][5];
$Sum_Mon = $ItemAmount*$ItemMoney;
echo number_format($Sum_Mon,2,".",",");
$ss_Order[$i][7]=$Sum_Mon;
?>
</div></td>
<td bgcolor="#FFFF99"><div align="center"><a href="Order.php?imgDel=<?=$i?>"><img src="image/delete.gif" width="19" height="19" border="0"></a></div></td>
</tr>
<? }?>
<tr>
<td colspan="4" bgcolor="#FFCCFF"><div align="right" class="style2"><strong>รวมทั้งหมด</strong></div></td>
<td bgcolor="#FFCCFF"><div align="right">
<?
//$total ;
for($i=0;$i < count($ss_Order); $i++){
$totalAmount += $ss_Order[$i][6];
}
echo number_format($totalAmount,2,".",",");
?>
</div></td>
<td colspan="2" bgcolor="#FFCCFF"><div align="right">
<?
//$total ;
for($i=0;$i < count($ss_Order); $i++){
$total_Price += $ss_Order[$i][7];
}
$f_Price = number_format($total_Price,2,".",",");
echo $f_Price;
?>
</div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="46%" bgcolor="#CCCCCC"><div align="right" class="style1">ราคาสินค้ารวมทั้งหมด</div></td>
<td width="11%" bgcolor="#CCCCCC"><div align="center"><strong><? echo $f_Price; ?></strong></div></td>
<td width="43%" bgcolor="#CCCCCC"><div align="left">
<strong>
<input type="hidden" name="Total_Price" id="Total_Price" value="<? echo $total_Price; ?>" />
<span class="style2">บาท</span></strong></div></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><div align="right" class="style1">ส่วนลด</div></td>
<td bgcolor="#CCCCCC"><div align="center" class="style45">ติดต่อพนักงาน</div></td>
<td bgcolor="#CCCCCC"><div align="left" class="style2">
%
</div></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><div align="right" class="style1">ยอดหักส่วนลด</div></td>
<td bgcolor="#CCCCCC"><div align="center"><strong>
<?
$Summary = ($txt_Discount*$total_Price)/100;
$F_Summ = number_format($Summary,2,".",",");
//
?>
<? echo $F_Summ; ?> </strong></div></td>
<td bgcolor="#CCCCCC"><div align="left"><strong>
<input type="hidden" id="Total_Discount" name="Total_Discount" value="<? echo $Summary; ?>" />
<span class="style2">บาท</span></strong></div></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><div align="right"><span class="style1">ยอดรวมสุทธิ</span><span class="style2"><strong></strong></span></div></td>
<td bgcolor="#CCCCCC"><div align="center"><strong>
<?
$Sum =$total_Price - $Summary;
$F_Sum = number_format($Sum,2,".",",");
?>
<? echo $F_Sum; ?></strong></div></td>
<td bgcolor="#CCCCCC"><div align="left"><strong>
<input type="hidden" id="Total_Summary" name="Total_Summary" value="<? echo$Sum; ?>" />
<span class="style2">บาท</span></strong></div></td>
</tr>
<tr>
<td colspan="3" bgcolor="#CCCCCC"><div align="right"></div><div align="left"></div></td>
</tr>
<tr>
<td colspan="3" bgcolor="#CCCCCC">
<div align="center">
<input name="btt_Order" type="submit" id="btt_Order" value="บันทึกการสั่งซื้อ" />
</div>
<div align="left"></div></td>
</tr>
</table>
</div></td>
</tr>
</table>
<br />
</form>
</div>
</body>
</html>
Tag : - - - -
|
|
|
|
|
|
Date :
2010-02-28 18:52:53 |
By :
noolek |
View :
882 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มี errer massage ไหม
|
|
|
|
|
Date :
2010-02-28 22:59:23 |
By :
onedan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|