|
|
|
รบกวนสอบถามเรื่องการ insert ข้อมูลภาษาไทย PHP + Oracle |
|
|
|
|
|
|
|
คือว่าผม insert ภาษาไทย เช่น แสงเทียน แต่พอ insert เข้าไปแล้วกลับได้ข้อมูลเป็น สงทน รบกวนแนะนำทีคับว่าต้องไปแก้ไขตรงไหน
หน้า form รับค่า
Code (PHP)
<?php
session_start();
if(($_SESSION['user_id']==NULL)){$Destination = 'index.php';header(sprintf("Location: %s",$Destination));}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=TIS-620">
<title>+ + Transport -Web+ +</title>
<link href="..\CSsDoc\style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style5 {
font-family: Tahoma;
font-size: 11px;
}
.style6 {font-family: Tahoma; font-size: 11px; font-weight: bold; }
-->
</style>
<script>
document.getElementById('docket_id').focus();
</script>
</head>
<body bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0" onload="document.getElementById('docket_id').focus()">
<tr>
<font face="Tahoma" color="#336699" size="2"><b>User:</b></font><font face="Tahoma" color="#FF3300" size="2">
<b><a href="menu.php"><? echo $user_id; ?></a></b></font><span class="style15"></span>
</tr>
<br>
<?
include "..\Connections\con_orcl_dhldbf.php";
$order_date = date("d/m/Y H:i:s");
$departure_date = date("d/m/Y H:i:s");
$plan_deliv_date = date("d/m/Y H:i:s");
?>
<form method="post" action="insert_update_transaction_ticket.php" name="checkForm" onSubmit = "return check()" >
<table border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#E7E7CF" class="normaltext">
<tr align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td colspan="2" class="ntextbold12"> </td>
</tr>
<tr align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td colspan="3" class="ntextbold12">
<div align="left"><strong>Transport Transaction Details </strong></div></td>
</tr>
<tr align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td colspan="2" class="ntextbold12"> </td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td width="107"><strong>Docket ID :</strong></td>
<td width="125" class="style5"><input name="docket_id" type="text" class="style5" id="docket_id" size="10" maxlength="10" >
<input type="hidden" name="today" id="today" value="<? echo date("m/d/Y H:i:s");?>"> <td width="118">DC_Name:
<span class="normaltext_red">
</span></td><td width="135"><span class="normaltext_red">
<select name="dc_id" size="1" class="textbox" id="dc_id">
<?
$sql_n = "select distinct tp_id,tp_name from tr_thirdparty where tp_type='1001'";
$curs_n = ora_open($connection);
ora_parse($curs_n, $sql_n);
ora_exec($curs_n);
$count_n = 0;
while(ora_fetch_into($curs_n, $chk_n, ORA_FETCHINTO_ASSOC))
{
$tp_id = $chk_n['TP_ID'];
$tp_name = $chk_n['TP_NAME'];
echo "<option value=$tp_id>$tp_name</option>";
$count_n++;
}
?>
</select>
</span></td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td>Order Date : </td>
<td class="style5"><span class="normaltext_red">
<input name="order_date" type="text" class="style5" id="order_date" value="<?php echo $order_date; ?>" size="18" maxlength="20" >
</span></td>
<td>Departure Date: </td>
<td><span class="normaltext_red">
<input name="departure_date" type="text" class="style5" id="departure_date" value="<?php echo $departure_date; ?>" size="18" maxlength="20" >
</span></td>
<td width="110">Estimate Date :</td>
<td width="266" ><span class="normaltext_red">
<input name="plan_deliv_date" type="text" class="style5" id="plan_deliv_date" value="<?php echo $plan_deliv_date; ?>" size="18" maxlength="20" >
</span>Roster:
<span class="normaltext_red">
<select name="roster_id" size="1" class="textbox" id="roster_id">
<?
$sql = "SELECT distinct parameter_id,parameter_name from tr_parameter WHERE parameter_type='ROST'";
$curs = ora_open($connection);
ora_parse($curs, $sql);
ora_exec($curs);
$count = 0;
while(ora_fetch_into($curs, $chk, ORA_FETCHINTO_ASSOC))
{
$parameter_id = $chk['PARAMETER_ID'];
$parameter_name = $chk['PARAMETER_NAME'];
echo "<option value=$parameter_name>$parameter_name</option>";
$count++;
}
?>
</select>
</span></td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td>Route :</td>
<td class="style5"><input name="route_no" type="text" class="style5" id="route_no" size="10" maxlength="10"></td>
<td>Store : </td>
<td><input name="store" type="text" class="style5" id="store" size="10" maxlength="10"> </td>
<td>Store Name : </td>
<td><input name="store_name" type="text" class="style5" id="store_name" size="10" maxlength="10" > </td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td>Truck ID : </td>
<td class="style5"><input name="truck_id" type="text" class="style5" id="truck_id" size="10" maxlength="15" > </td>
<td>Truck Driver : </td>
<td><input name="truck_driver" type="text" class="style5" id="truck_driver" size="15" maxlength="26"> </td>
<td>Pallet QTY : </td>
<td><input name="pallet_qty" type="text" class="style5" id="pallet_qty" size="10" maxlength="10" > </td>
</tr> <tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td>Cartons QTY : </td>
<td class="style5"><input name="carton_qty" type="text" class="style5" id="carton_qty" size="10" maxlength="10" > </td>
<td >Seal No : </td>
<td class="style5" colspan="2"><input name="seal_send" type="text" class="style5" id="seal_send" size="10" maxlength="20">
ถ้ามีมากกว่า 1 หมายเลขให้คั่นด้วย # </td>
<td><span class="style5">
<label>
<input type="checkbox" name="chk" value="1" id="chk">
สำเนาร่วม</label>
</span>
</td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td colspan="6">
<table border="0"width="842">
<tr>
<td width="127"><div align="center" class="style1 style6 style7">
<div align="left">รายการ</div>
</div></td>
<td width="97"><div align="center" class="style1 style6 style8">
<div align="left">จำนวนพาเลท</div>
</div></td>
<td width="120"><div align="center" class="style6">
<div align="left">รายการ</div>
</div></td>
<td width="67"><div align="center" class="style6">
<div align="left">จำนวนพาเลท</div>
</div></td>
<td width="137"><div align="center" class="style6">
<div align="left">รายการ</div>
</div></td>
<td width="67"><div align="center" class="style6">
<div align="left">จำนวนพาเลท</div>
</div></td>
<td width="126"><div align="center" class="style6">
<div align="left">รายการ</div>
</div></td>
<td width="67"><div align="center" class="style6">
<div align="left">จำนวนพาเลท</div>
</div></td>
</tr>
<tr>
<td width="127"><span class="style5">
<label>
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="d501">
</label>
Dry สีเหลือง(PY)</span></td>
<td width="97"><input name="d501" type="text" id="d501" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="n505">
NF สีเหลือง(NY)</span></td>
<td><input name="n505" type="text" id="n505" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="x509" />
XDock สีเหลือง(CY)</span></td>
<td><span class="style5">
<label>
<input name="x509" type="text" id="x509" size="10">
</label>
</span></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="r515" />
RTV สีเหลือง(RY)</span></td>
<td><input name="r515" type="text" id="r515" size="10"></td>
</tr>
<tr>
<td width="127"><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="d502">
Dry สีฟ้า(PฺB)</span></td>
<td width="97"><input name="d502" type="text" id="d502" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="n506">
NF สีฟ้า(NB)</span></td>
<td><input name="n506" type="text" id="n506" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="x510" />
XDock ฟ้า(CB)</span></td>
<td><input name="x510" type="text" id="x510" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="r516" />
RTV สีฟ้า(RB)</span></td>
<td><input name="r516" type="text" id="r516" size="10"></td>
</tr>
<tr>
<td width="127"><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="d503">
Dry สีเขียว(PG)</span></td>
<td width="97"><input name="d503" type="text" id="d503" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="n507">
NF สีเขียว(NG)</span></td>
<td><input name="n507" type="text" id="n507" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="x511" />
XDock เขียว(CG)</span></td>
<td><input name="x511" type="text" id="x511" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="r517" />
RTV สีเขียว(RG)</span></td>
<td><input name="r517" type="text" id="r517" size="10"></td>
</tr>
<tr>
<td width="127"><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="d504">
Dry สินค้าอื่นๆ(PZ)</span></td>
<td width="97"><input name="d504" type="text" id="d504" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="n508">
NF สินค้าอื่นๆ(NZ)</span></td>
<td><input name="n508" type="text" id="n508" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="x512" />
XDock สินค้าอื่นๆ(CZ)</span></td>
<td><input name="x512" type="text" id="x512" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="r518" />
RTV สินค้าอื่นๆ(RZ)</span></td>
<td><input name="r518" type="text" id="r518" size="10"></td>
</tr>
<tr>
<td width="127"><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="n523">
FT สีฟ้า (FB)
</span></td>
<td width="97"><span class="style5">
<input name="n523" type="text" id="n523" size="10">
</span></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="n521">
FT สีเหลือง (FY)</span></td>
<td><span class="style5">
<input name="n521" type="text" id="n521" size="10">
</span></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="x513" />
HP กระเช้า(HP)</span></td>
<td><input name="x513" type="text" id="x513" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="r519" />
ถุงน้ำตาล ข้าว(S1)</span></td>
<td><input name="r519" type="text" id="r519" size="10"></td>
</tr>
<tr>
<td width="127"><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="n524">
FT สีเขียว (FG)</span></td>
<td width="97"><span class="style5">
<input name="n524" type="text" id="n524" size="10">
</span></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="n522">
FF สินค้าอื่นๆ(FZ)</span></td>
<td><span class="style5">
<input name="n522" type="text" id="n522" size="10">
</span></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="x514" />
NBH (MS)</span></td>
<td><input name="x514" type="text" id="x514" size="10"></td>
<td><span class="style5">
<input name="pckg_id[]" type="checkbox" id="pckg_id[]" value="r520" />
อื่นๆ (ZZ)</span></td>
<td><input name="r520" type="text" id="r520" size="10"></td>
</tr>
</table> </td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td colspan="6" align="right"><div align="center"><img src="../images/media-floppy.gif" width="16" height="16">
<input name="Save" type="submit" class="submitwhite" id="Save" value="Save">
<img src="../images/arrow_refresh.gif" width="16" height="16">
<input name="Refresh" type="reset" class="submitwhite" id="Refresh" value="Refresh">
</div></td>
<td width="56"> </td>
<td width="46"></td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td colspan="2"> </td>
</tr>
</table>
<script language="javascript">
function check() {
if(document.checkForm.docket_id.value=="") {
alert("Please!!! Input Docket ID") ;
document.checkForm.docket_id.focus() ;
return false ;
}
else
return true ;
}
</script>
</form>
</body>
</html>
หน้า insert
Code (PHP)
<?php
session_start();
$pckg_id = $_POST['pckg_id'];
$d501 = $_POST[d501];
$d502 = $_POST[d502];
$d503 = $_POST[d503];
$d504 = $_POST[d504];
$n505 = $_POST[n505];
$n506 = $_POST[n506];
$n507 = $_POST[n507];
$n508 = $_POST[n508];
$x509 = $_POST[x509];
$x510 = $_POST[x510];
$x511 = $_POST[x511];
$x512 = $_POST[x512];
$x513 = $_POST[x513];
$x514 = $_POST[x514];
$r515 = $_POST[r515];
$r516 = $_POST[r516];
$r517 = $_POST[r517];
$r518 = $_POST[r518];
$r519 = $_POST[r519];
$r520 = $_POST[r520];
$n521 = $_POST[n521];
$n522 = $_POST[n522];
$n523 = $_POST[n523];
$n524 = $_POST[n524];
$docket_id = $_POST[docket_id];
$order_date = $_POST[order_date];
$departure_date = $_POST[departure_date];
$plan_deliv_date = $_POST[plan_deliv_date];
$route_no = $_POST[route_no];
$store = $_POST[store];
$store_name = $_POST[store_name];
$truck_id = $_POST[truck_id];
$truck_driver = $_POST[truck_driver];
$pallet_qty = $_POST[pallet_qty];
$carton_qty = $_POST[carton_qty];
$seal_send = $_POST[seal_send];
$tp_id = $_POST[tp_id];
$tp_id=$dc_id;
$parameter_name = $_POST[parameter_name];
$parameter_name=$roster_id;
$chk=$_POST[chk];
if($chk=='1')
{
$chk='Y';
}else
{
$chk='N';
}
include "..\Connections\con_orcl_dhldbf.php";
$sql_h="select * from tr_trans where docket_id ='$_POST[docket_id]'";
$curs_h = ora_open($connection);
ora_parse($curs_h, $sql_h);
ora_exec($curs_h);
$row = 0;
while(ora_fetch_into($curs_h, $chk_h, ORA_FETCHINTO_ASSOC))
{
$docket_id = $chk_h['DOCKET_ID'];
$row++;
ora_commit($connection);
}
//echo $row;
if ($row != 0) {
$error=13;
echo "<meta http-equiv=\"refresh\" content=\"3; URL=messages.php?messages=$error\">";
}else{
//echo count($chk);
if (isset($pckg_id)){
foreach ($pckg_id as $value) {
if (isset($value)){
$sql="insert into tr_transd(docket_id,cust_id,truck_id,pckg_id,pckg_qty,trans_type,trans_dtim)
values ('$docket_id','$store','$truck_id','".$value."','".$$value."','T',sysdate)";
$curs = ora_open($connection);
ora_commitoff($connection);
//echo $sql;
if(!@ora_parse($curs, $sql))
{
$error=9;
echo "<meta http-equiv=\"refresh\" content=\"0; URL=messages.php?messages=$error\">";
ora_rollback($connection);
}
else
{
$error=8;
echo "<meta http-equiv=\"refresh\" content=\"0; URL=messages.php?messages=$error\">";
ora_exec($curs);
ora_commit($connection);
}
}
}
$sql="insert into tr_trans(docket_id,cust_id,truck_id,truck_driver,deliv_dtim,ord_dtim,plan_deliv_dtim,route_id,pall_qty,
cart_qty,seal_send,create_dtim,create_user,change_dtim,change_user,docket_status,cust_name,roster_id,doc_join,dc_id)
values ('$docket_id','$store','$truck_id','$truck_driver',to_date('$departure_date','dd/mm/yyyy HH24:mi:ss'),
to_date('$order_date','dd/mm/yyyy HH24:mi:ss'),to_date('$plan_deliv_date','dd/mm/yyyy HH24:mi:ss'),
'$route_no','$pallet_qty','$carton_qty','$seal_send',sysdate,'$user_id',sysdate,'$user_id','T','$store_name','$roster_id','$chk','$dc_id')";
$curs = ora_open($connection);
//echo $sql;
if(!@ora_parse($curs, $sql))
{
$error=9;
echo "<meta http-equiv=\"refresh\" content=\"3; URL=messages.php?messages=$error\">";
ora_rollback($connection);
}
else
{
$error=8;
echo "<meta http-equiv=\"refresh\" content=\"3; URL=messages.php?messages=$error\">";
ora_exec($curs);
ora_commit($connection);
}
}else {
$sql="insert into tr_trans(docket_id,cust_id,truck_id,truck_driver,deliv_dtim,ord_dtim,plan_deliv_dtim,route_id,pall_qty,
cart_qty,seal_send,create_dtim,create_user,change_dtim,change_user,docket_status,cust_name,roster_id,doc_join,dc_id)
values ('$docket_id','$store','$truck_id','$truck_driver',to_date('$departure_date','dd/mm/yyyy HH24:mi:ss'),
to_date('$order_date','dd/mm/yyyy HH24:mi:ss'),to_date('$plan_deliv_date','dd/mm/yyyy HH24:mi:ss'),
'$route_no','$pallet_qty','$carton_qty','$seal_send',sysdate,'$user_id',sysdate,'$user_id','T','$store_name','$roster_id','$chk','$dc_id')";
$curs = ora_open($connection);
//echo $sql;
if(!@ora_parse($curs, $sql))
{
$error=9;
echo "<meta http-equiv=\"refresh\" content=\"3; URL=messages.php?messages=$error\">";
ora_rollback($connection);
}
else
{
$error=8;
echo "<meta http-equiv=\"refresh\" content=\"3; URL=messages.php?messages=$error\">";
ora_exec($curs);
ora_commit($connection);
}
$sql="insert into tr_transd(docket_id,cust_id,truck_id,pckg_id,pckg_qty,trans_type,trans_dtim)
values ('$docket_id','$store','$truck_id','0','0','T',sysdate)";
$curs = ora_open($connection);
//echo $sql;
if(!@ora_parse($curs, $sql))
{
$error=9;
echo "<meta http-equiv=\"refresh\" content=\"3; URL=messages.php?messages=$error\">";
ora_rollback($connection);
}
else
{
$error=8;
echo "<meta http-equiv=\"refresh\" content=\"3; URL=messages.php?messages=$error\">";
ora_exec($curs);
ora_commit($connection);
}
}
ora_close($curs);
}
?>
Tag : - - - -
|
|
|
|
|
|
Date :
2010-07-16 10:22:03 |
By :
php |
View :
2523 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลอง echo ค่าตอนก่อน insert ดูสิครับ ว่าได้ค่าถูกต้องแล้วหรือยัง
|
|
|
|
|
Date :
2010-07-16 11:40:42 |
By :
50121680 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo ดูแล้วได้ค่าไม่ถูกต้องครับ ต้อง check ตรงไหนต่อคับ
|
|
|
|
|
Date :
2010-07-16 15:13:35 |
By :
php |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Check หมดแล้วก็ยังงไม่ได้เลยอ่ะ
แต่ถ้าเปลี่ยนตรงหัว html เป็น utf-8 ส่งค่ามาถูกต้องแต่พอเอาบันทึกดันเป็นภาษา
อย่างนี้
"ธษธสษษษษาธธธธ"
|
|
|
|
|
Date :
2010-09-17 10:50:23 |
By :
xcom |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|