|
|
|
รบกวนช่วยดูโค้ดให้หน่อยค่ะ insert เข้า database ไม่เข้าอ่ะค่ะ |
|
|
|
|
|
|
|
------------------------------- อันนี้หน้า form คะ
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Invoice </title>
<script type="text/javascript">
function cal601(){
var value1 = parseFloat(document.form.m601.value);
var value2 = parseFloat(document.form.p601.value);
var total = value1*value2;
//document.getElementByName('total601').innerHTML= total;
document.form.total601.value=total;
}
function cal602(){
var value3 = parseFloat(document.form.m602.value);
var value4 = parseFloat(document.form.p602.value);
var total2 = value3*value4;
//document.getElementByName('total601').innerHTML= total;
document.form.total602.value=total2;
}
function cal605(){
var value3 = parseFloat(document.form.m605.value);
var value4 = parseFloat(document.form.p605.value);
var total2 = value3*value4;
//document.getElementByName('total601').innerHTML= total;
document.form.total605.value=total2;
}
function cal603(){
var value3 = parseFloat(document.form.m603.value);
var value4 = parseFloat(document.form.p603.value);
var total2 = value3*value4;
//document.getElementByName('total601').innerHTML= total;
document.form.total603.value=total2;
}
function cal604(){
var value3 = parseFloat(document.form.m604.value);
var value4 = parseFloat(document.form.p604.value);
var total2 = value3*value4;
//document.getElementByName('total601').innerHTML= total;
document.form.total604.value=total2;
}
function caltotal60(){
var value1,value2,value3,value4,value5 = 0;
value1 = parseFloat(document.form.total601.value);
value2 = parseFloat(document.form.total602.value);
value3 = parseFloat(document.form.total603.value);
value4 = parseFloat(document.form.total604.value);
value5 = parseFloat(document.form.total605.value);
total2 = value1+value2+value3+value4+value5;
//document.getElementByName('total601').innerHTML= total;
document.form.total60.value=total2;
}
function calM60(){
var value1,value2,value3,value4,value5 = 0;
value1 = parseFloat(document.form.m601.value);
value2 = parseFloat(document.form.m602.value);
value3 = parseFloat(document.form.m603.value);
value4 = parseFloat(document.form.m604.value);
value5 = parseFloat(document.form.m605.value);
M60 = value1+value2+value3+value4;
document.form.ytotal60.value=M60;
document.form.s60.value = M60;
document.form.stotal60.value = M60*4;
}
function cal441(){
var value3 = parseFloat(document.form.m441.value);
var value4 = parseFloat(document.form.p441.value);
var total2 = value3*value4;
//document.getElementByName('total601').innerHTML= total;
document.form.total441.value=total2;
}
function cal442(){
var value3 = parseFloat(document.form.m442.value);
var value4 = parseFloat(document.form.p442.value);
var total2 = value3*value4;
//document.getElementByName('total601').innerHTML= total;
document.form.total442.value=total2;
}
function cal443(){
var value3 = parseFloat(document.form.m443.value);
var value4 = parseFloat(document.form.p443.value);
var total2 = value3*value4;
//document.getElementByName('total601').innerHTML= total;
document.form.total443.value=total2;
}
function cal444(){
var value3 = parseFloat(document.form.m444.value);
var value4 = parseFloat(document.form.p444.value);
var total2 = value3*value4;
//document.getElementByName('total601').innerHTML= total;
document.form.total444.value=total2;
}
function cal445(){
var value3 = parseFloat(document.form.m445.value);
var value4 = parseFloat(document.form.p445.value);
var total2 = value3*value4;
//document.getElementByName('total601').innerHTML= total;
document.form.total445.value=total2;
}
function caltotal44(){
var value1,value2,value3,value4,value5 = 0;
//var total44 = 0;
value1 = parseFloat(document.form.total441.value);
value2 = parseFloat(document.form.total442.value);
value3 = parseFloat(document.form.total443.value);
value4 = parseFloat(document.form.total444.value);
value5 = parseFloat(document.form.total445.value);
total44 = value1+value2+value3+value4+value5;
document.form.t44.value = total44;
}
function calM44(){
var value1,value2,value3,value4,value5 = 0;
value1 = parseFloat(document.form.m441.value);
value2 = parseFloat(document.form.m442.value);
value3 = parseFloat(document.form.m443.value);
value4 = parseFloat(document.form.m444.value);
value5 = parseFloat(document.form.m445.value);
M44 = value1+value2+value3+value4+value5;
document.form.ytotal44.value=M44;
document.form.s44.value = M44;
document.form.stotal44.value = M44*3.5;
}
function calYtotal(){
var value1,value2,value3,value4,value5 = 0;
value1 = parseFloat(document.form.total441.value);
value2 = parseFloat(document.form.total442.value);
value3 = parseFloat(document.form.total443.value);
value4 = parseFloat(document.form.total444.value);
value5 = parseFloat(document.form.total445.value);
value6 = parseFloat(document.form.total601.value);
value7= parseFloat(document.form.total602.value);
value8 = parseFloat(document.form.total603.value);
value9 = parseFloat(document.form.total604.value);
value10 = parseFloat(document.form.total605.value);
rate = parseFloat(document.form.rate.value);
total = value6+value7+value8+value9+value10+value1+value2+value3+value4+value5;
document.form.total.value = total;
document.form.btotal.value= total*rate;
}
function caltotal(){
var value1,value2,value3 = 0;
value1 = parseFloat(document.form.btotal.value);
value2= parseFloat(document.form.stotal44.value);
value3= parseFloat(document.form.stotal60.value);
total = value1+value2+value3;
document.form.alltotal.value = total;
}
</script>
</head>
<body>
<form action="DW-invoice-insert.php" method="post" name="form">
<table width="80%" style="margin-left:0px">
<tr>
<td>วันที่ใบแจ้งหนี้:</td>
<td><input name="date" type="text" /></td>
</tr>
<tr>
<td>ชื่อลููกหนี้</td>
<td> <input name="Sname" type="text" value="ดีวรรณพาณิชย์" /><br /><br /></td>
</tr>
<tr>
<td>เลขที่ตู้สินค้า: </td>
<td><input name="Ctns" type="text" /><br /><br /></td>
</tr>
<tr>
<td> Rate<br /><br /> </td>
<td> <input name="rate" type="text" id="rate" /> บาท/หยวน <br /><br /></td>
</tr>
<!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
<!-- 60" -->
<tr>
<td>รายการสินค้า: <br /><br /></td>
<td> หน้ากว้าง 60"<br /><br /></td>
</tr>
<tr>
<td></td>
<td> ชื่อผ้า <input name="name601" type="text" /> <br /><br /></td>
<td>จำนวน <input name="m601" type="text" size="10" onblur="calM60()" value="0"/> เมตร<br /><br /></td>
<td> ราคา <input name="p601" type="text" size="4" onblur="cal601();caltotal60();calYtotal();caltotal()" value="0"/> หยวน/เมตร <br /><br /></td>
<td> รวม <input name="total601" type="text" size="10" id="total601" value="0"/><b id="total"></b> หยวน<br /><br /></td>
</tr>
<tr>
<td></td>
<td> ชื่อผ้า <input name="name602" type="text" /> <br /><br /></td>
<td>จำนวน <input name="m602" type="text" size="10" value="0" onblur="calM60()" /> เมตร<br /><br /></td>
<td> ราคา <input name="p602" type="text" size="4" onblur="cal602();calYtotal();caltotal60();caltotal()" /> หยวน/เมตร <br /><br /></td>
<td> รวม <input name="total602" type="text" size="10" id="total602" value="0"/><b id="total602"</b> หยวน</td>
<tr>
<tr>
<td></td>
<td> ชื่อผ้า <input name="name603" type="text" /> <br /><br /></td>
<td>จำนวน <input name="m603" type="text" size="10" value="0" onblur="calM60()"/> เมตร<br /><br /></td>
<td> ราคา <input name="p603" type="text" size="4" onblur="cal603();calYtotal();caltotal60();caltotal()" /> หยวน/เมตร <br /><br /></td>
<td> รวม <input name="total603" type="text" size="10" id="total603" value="0"/> หยวน</td>
<tr>
<tr>
<td></td>
<td> ชื่อผ้า <input name="name604" type="text" onfocus="calM60()" /> <br /><br /></td>
<td>จำนวน <input name="m604" type="text" size="10" value="0" onblur="calM60()" /> เมตร<br /><br /></td>
<td> ราคา <input name="p604" type="text" size="4" onblur="cal604();calYtotal();caltotal60();caltotal()" /> หยวน/เมตร <br /><br /></td>
<td> รวม <input name="total604" type="text" size="10" id="total604" value="0"/> หยวน</td>
<tr>
<tr>
<td></td>
<td> ชื่อผ้า <input name="name605" type="text" /> <br /><br /></td>
<td>จำนวน <input name="m605" type="text" size="10" value="0" onblur="calM60()" /> เมตร<br /><br /></td>
<td> ราคา <input name="p605" type="text" size="4" onblur="cal605();calYtotal();caltotal60();caltotal()" /> หยวน/เมตร <br /><br /></td>
<td> รวม <input name="total605" type="text" size="10" id="total605" value="0"/> หยวน</td>
<tr>
<tr>
<td></td>
<td></td>
<td style="text-align:center"> รวม 60" <input name="ytotal" type="text" id="ytotal60" onfocus="calM60()" value="0"/> เมตร </td>
<td> <input name="total60" type="text" id="total60" onfocus="cal60()" value="0"/> หยวน</td>
</tr>
<!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >
<!-- 44" -->
<tr>
<td></td>
<td> หน้ากว้าง 44"<br /><br /></td>
</tr>
<tr>
<td></td>
<td> ชื่อผ้า <input name="name441" type="text" onFocus="caltotal60()"/> <br /><br /></td>
<td>จำนวน <input name="m441" type="text" size="10" onblur="calM44()" value="0"/> เมตร<br /><br /></td>
<td> ราคา <input name="p441" type="text" size="4" onblur="cal441();caltotal44();calYtotal()"/> หยวน/เมตร <br /><br /></td>
<td> รวม <input name="total441" type="text" size="10" id="total441" value="0" /> หยวน</td>
</tr>
<tr>
<td></td>
<td> ชื่อผ้า <input name="name442" type="text" /> <br /><br /></td>
<td>จำนวน <input name="m442" type="text" size="10" onblur="calM44()" value="0" /> เมตร<br /><br /></td>
<td> ราคา <input name="p442" type="text" size="4" onblur="cal442();caltotal44();calYtotal()" /> หยวน/เมตร <br /><br /></td>
<td> รวม <input name="total442" type="text" size="10" id="total442" value="0" /> หยวน</td>
<tr>
<tr>
<td></td>
<td> ชื่อผ้า <input name="name443" type="text" /> <br /><br /></td>
<td>จำนวน <input name="m443" type="text" size="10" value="0" onblur="calM44()" /> เมตร<br /><br /></td>
<td> ราคา <input name="p443" type="text" size="4" onblur="cal443();caltotal44();calYtotal()" /> หยวน/เมตร <br /><br /></td>
<td> รวม <input name="total443" type="text" size="10" id="total443" value="0"/> หยวน</td>
<tr>
<tr>
<td></td>
<td> ชื่อผ้า <input name="name444" type="text" /> <br /><br /></td>
<td>จำนวน <input name="m444" type="text" size="10" value="0" onblur="calM44()" /> เมตร<br /><br /></td>
<td> ราคา <input name="p444" type="text" size="4" onblur="cal444();caltotal44();calYtotal()"/> หยวน/เมตร <br /><br /></td>
<td> รวม <input name="total444" type="text" size="10" id="total444" value="0"/> หยวน</td>
<tr>
<tr>
<td></td>
<td> ชื่อผ้า <input name="name445" type="text" /> <br /><br /></td>
<td>จำนวน <input name="m445" type="text" size="10" value="0" onblur="calM44()" /> เมตร<br /><br /></td>
<td> ราคา <input name="p445" type="text" size="4" onblur="cal445();caltotal44();calYtotal()" /> หยวน/เมตร <br /><br /></td>
<td> รวม <input name="total445" type="text" size="10" id="total445" value="0" /> หยวน</td>
</tr>
<tr>
<td></td>
<td></td>
<td style="text-align:center">รวม 44" <input name="ytotal44" type="text" id="ytotal44"/> เมตร <br /><br /></td>
<td><input name="t44" type="text" id="t44" /> หยวน<br /><br /></td>
</tr>
<!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
<tr>
<td> รวมค่าสินค้า <br /><br /></td>
<td> <input name="yprice" type="text" value="0" id="total"/> หยวน x RATE = <br /><br /></td>
<td> <input name="total" type="text" id="btotal" value="0" maxlength="10"/> บาท<br /><br /></td>
</tr>
<!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ค่าขนส่งงง------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
<tr>
<td> ค่าขนส่งสินค้า 44"<br /><br /></td>
<td> <input name="s44" type="text" value="0" id="s44"/> เมตร x 3.5 บาท = </td>
<td><input name="sb44" type="text" id="stotal44" value="0"/> บาท<br /><br /></td>
</tr>
<tr>
<td> ค่าขนส่งสินค้า 60"<br /><br /></td>
<td> <input name="s60" type="text" value="0" id="s60"/> เมตร x 4 บาท = </td>
<td><input name="sb60" type="text" id="stotal60" value="0"/> บาท<br /><br /></td>
</tr>
<!--<tr>
<td> รวม <br /><br /></td>
<td> <input name="ytotal" type="text" /> บาท <br /><br /></td>
</tr>-->
<tr>
<td> รวมทั้งสิ้น<br /><br /></td>
<td> <input name="Btotal" type="text" id="alltotal" /> บาท <br /><br /></td>
</tr>
<tr>
<td style="text-align:center"> <input name="" type="submit" /></td>
</tr>
</table>
</form>
</body>
</html>
------------------------------------------------------------------------------------------------------------------------------------------------------
หน้า ใส่ข้อมูลค่ะ
<!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=utf-8" />
<title>DW Insert</title>
</head>
<body>
<?php
$con = mysql_connect("localhost","root","1234");
if(!$con)
{
die('Could not connect: ' .mysql_error());
}
//mysql_query("SET_CHARACTER_SET_utf8");
//mysql_query("SET collation_connection = ’utf8_thai_ci’ ");
mysql_select_db("KWS",$con);
//mysql_query("SET NAMES UTF8");
// escape variables for security
$date = $_POST['date'];
$Name = $_POST['Sname'];
$Ctns = $_POST['Ctns'];
$Rate = $_POST['rate'];
$d601 = $_POST['name601'];
$d602 = $_POST['name602'];
$d603 = $_POST['name603'];
$d604 = $_POST['name604'];
$d605 = $_POST['name605'];
$m601 = $_POST['m601'];
$m602 = $_POST['m602'];
$m603 = $_POST['m603'];
$m604 = $_POST['m604'];
$m605 = $_POST['m605'];
$p601 = $_POST['p601'];
$p602 = $_POST['p602'];
$p603 = $_POST['p603'];
$p604 = $_POST['p604'];
$p605 = $_POST['p605'];
$t601 = $_POST['total601'];
$t602 = $_POST['total602'];
$t603 = $_POST['total603'];
$t604 = $_POST['total604'];
$t605 = $_POST['total605'];
$m60 = $_POST['ytotal'];
$t60 = $_POST['total60'];
$d441 = $_POST['name441'];
$d442 = $_POST['name442'];
$d443 = $_POST['name443'];
$d444 = $_POST['name444'];
$d445 = $_POST['name445'];
$m441 = $_POST['m441'];
$m442 = $_POST['m442'];
$m443 = $_POST['m443'];
$m444 = $_POST['m444'];
$m445 = $_POST['m445'];
$p441 = $_POST['p441'];
$p442 = $_POST['p442'];
$p443 = $_POST['p443'];
$p444 = $_POST['p444'];
$p445 = $_POST['p445'];
$t441 = $_POST['total441'];
$t442 = $_POST['total442'];
$t443 = $_POST['total443'];
$t444 = $_POST['total444'];
$t445 = $_POST['total445'];
$m44 = $_POST['ytotal44'];
$t44 = $_POST['t44'];
$yprice = $_POST['yprice'];
$btotal = $_POST['btotal'];
$s44 = $_POST['sb44'];
$s60 = $_POST['sb60'];
$total = $_POST['allt'];
$sql="INSERT INTO dw-invoice"." (date
,name,Ctns,rate,d601,m601,p601,t601,d602,m602,p602,t602,d603,m603,p603,t603,d604,m604,p604,t604,d605,m605,p605,t605,m60,t60,d441,m441,p441,t441,d442,m442,p442,t442,d443,m443,p444,t444,d444,m444,p444,t444,d445,m445,p445,t445,m44,t44,Yprice,btotal,stotal44,stotal60,allt)"."VALUES('$date','$Name','$Ctns','$Rate','$d601','$m601','$p601','$t601','$d602','$m602','$p602','$t602','$d603','$m603','$p603','$t603','$d604','$m604','$p604','$t604','$d605','$m605','$p605','$t605','$m60','$t60','$d441','$m441','$p441','$t441','$d442','$m442','$p442','$t442','$d443','$m443','$p444','$t444','$d444','$m444','$p444','$t444','$d445','$m445','$p445','$t445','$m44','$t44','$yprice',
'$btotal','$s44','$s60','$total')";
$query = mysql_query($sql,$con);
if(!$query)
{
die('Could not enter data ' .mysql_error());
}
echo "entered";
mysql_close($con);
?>
</body>
</html>
รบกวนหน่อยนะคะ ขอบคุนล่วงหน้าค่ะ
Tag : PHP, HTML/CSS, JavaScript, CakePHP
|
|
|
|
|
|
Date :
2014-06-19 18:08:43 |
By :
banban37 |
View :
829 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยเอา feature PHP ครอบ code หน่อยครับ จะได้อ่านง่าย ครับ
สำหรับวันนี้ คงไม่ไหวแล้วครับ สวัสดีครับ
|
|
|
|
|
Date :
2014-06-19 22:40:13 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|