|
 |
|
ทำไมผมถึง Insert ข้อมูลลง database ไมได้ซักที ทำมาทั้งวันแร้ว T_T |
|
 |
|
|
 |
 |
|
รบกวนผู้รู้ช่วยทีคับ ขอบคุณคับ
แนบรูปภาพและโค้ดคับ

Code (PHP)
<form action="save.php" name="frmAdd" method="POST">
<table width="100%" border="1" align="center">
<tr>
<td colspan="7"><div align="center"><strong>โปรแกรมคำนวณระยะเวลา</strong></div></td>
</tr>
<tr>
<td colspan="7"> </td>
</tr>
<tr>
<th width="10%"> <div align="center">วันที่</div></th>
<th width="15%"> <div align="center">จำนวนรายการ</div></th>
<th width="15%"><div align="center">เวลารับ</div></th>
<th width="15%"> <div align="center">เวลาคีย์</div></th>
<th width="15%"><div align="center">เวลาเช็ค</div></th>
<th width="15%"> <div align="center">รับใบที่ชำระเงินแล้ว</div></th>
<th width="15%"> <div align="center">เวลาจ่าย</div></th>
</tr>
<tr>
<td><div align="center"><input type="text" name="txtp_day" size="5"></div></td>
<td><div align="center"><input type="text" name="txtamount" size="5"></div></td>
<td><div align="center">
<input type="text" name="txtget_h" size="5">
<input type="text" name="txtget_m" size="5" />
</div></td>
<td><div align="center">
<input type="text" name="txtkey_h" size="5">
<input type="text" name="txtkey_m" size="5" />
</div></td>
<td><div align="center">
<input type="text" name="txtcheck_h" size="5">
<input type="text" name="txtcheck_m" size="5" />
</div></td>
<td align="right"><div align="center">
<input type="text" name="txtcash_h" size="5">
<input type="text" name="txtcash_m" size="5" />
</div></td>
<td align="right"><div align="center">
<input type="text" name="txtdispend_h" size="5">
<input type="text" name="txtdispend_m" size="5" />
</div></td>
</tr>
</table>
<p> </p>
<p align="center">
<input type="submit" name="submit" value="submit">
</p>
</form>
หน้า save.php
Code (PHP)
<?php
$objConnect = mysql_connect("localhost","root","123456") or die("Error Connect to Database");
$objDB = mysql_select_db("drug");
$strSQL = "INSERT INTO order ";
$strSQL .="(p_day, amount, get_h, get_m, key_h, key_m, check_h, check_m, cash_h, cash_m, dispend_h, dispend_m)";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtp_day"]."','".$_POST["txtamount"]."','".$_POST["txtget_h"]."','".$_POST["txtget_m"]."','".$_POST["txtkey_h"]."','".$_POST["txtkey_m"]."'";
$strSQL .=",'".$_POST["txtcheck_h"]."','".$_POST["txtcheck_m"]."','".$_POST["txtcash_h"]."','".$_POST["txtcash_m"]."','".$_POST["txtdispend_h"]."','".$_POST["txtdispend_m"]."')";
$objQuery = mysql_query($strSQL);
if($objQuery){
echo "Save Done.";
}else{
echo "Errorrrrrrrrrrrrrrrrrrrrrrrrrrrr";
}
mysql_close($objConnect);
?>
database

Tag : PHP, MySQL, HTML/CSS

|
|
 |
 |
 |
 |
Date :
2012-04-09 16:45:08 |
By :
smartboyy |
View :
1135 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$objQuery = mysql_query($strSQL) or die(mysql_error());
เพิ่มนี่เข้าไปครับ
|
 |
 |
 |
 |
Date :
2012-04-09 16:52:33 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง echo $strSQL ก่อน query ออกมาดูแล้ว copy ไปรันที่ phpmyadmin ดูครับ
|
 |
 |
 |
 |
Date :
2012-04-09 17:00:23 |
By :
jeabz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แร้วคับพี่วิน เป็นอย่างที่พี่วินบอกจริงด้วย
order ต้องใช้ `order`
ขอบคุณมากคับ
|
 |
 |
 |
 |
Date :
2012-04-09 17:20:53 |
By :
smartboyy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|