Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > เกิดปัญหาอะครับ คือว่า มัน insert ไม่ลงฐานข้อมูลอ่ะครับ ช่วยแก้ปัญหาให้ทีครับ



 

เกิดปัญหาอะครับ คือว่า มัน insert ไม่ลงฐานข้อมูลอ่ะครับ ช่วยแก้ปัญหาให้ทีครับ

 



Topic : 081098



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์




Order.php
Code (PHP)
<html>
<head>
<title>สั่งซื้อสินค้า</title>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<script type="text/javascript">   
var cnt = 0;   
var tbl = null;   
function init()   
{   
    tbl = document.getElementById('tbl');   
}   
function addRow()   
{   
    cnt++;   
    var tr = tbl.insertRow(tbl.rows.length - 2);   
    tr.id = 'tr_' + cnt;   
    var td = tr.insertCell(0);
    var s = '<p align="left"><font size="2">';
	s += '&nbsp;&nbsp;รหัสสินค้า : <input name="Product_ID[]" type="text" size="5" maxlength="10" id="Product_ID_' + cnt + '"> ';  
    s += '&nbsp;&nbsp;ชื่อสินค้า : <input name="Product_Name[]" type="text" size="40" maxlength="200" id="Product_Name_' + cnt + '"> ';   
    s += '&nbsp;&nbsp;จำนวนที่ซื้อ : <input name="Quantity[]" type="text" size="5" maxlength="5" id="Quantity_' + cnt + '"> ';   
    s += '&nbsp;&nbsp;ราคาต่อหน่วย : <input name="Price[]" type="text" size="10" maxlength="10" id="Price_' + cnt + '">';   
    s += ' <a href="#" onclick="return removeRow(' + cnt + ')">(เอาออก)</a>';
    s += '</font></p>';
    td.innerHTML = s;   
    return false;   
}  
function removeRow(id)   
{   
    var o = document.getElementById('tr_'+id);   
    tbl.deleteRow(o.rowIndex);   
    return false;   
}   
</script>   
<style>
BODY {
    FONT-FAMILY: Arial, Helvetica, sans-serif
}
.style1 {font-size: xx-large;
	color: #0000FF;
}
.style12 {font-family: "Angsana New"}
</style>
</head>

<body onLoad="init()">
<table width="100%" height="130" border="1">
  <tr>
    <th height="87" colspan="5" scope="col"><strong><span class="style1">ระบบบริการการจัดการร้านซักรีดออนไลน์</span></strong></th>
  </tr>
  <tr>
    <th width="152" height="37" scope="col"><span class="style12"><a href="HomePage.php">หน้าแรก</a></span></th>
    <th scope="col"><a href="Product.php">รายการสินค้า</a></th>
    <th scope="col"><a href="Member.php">รายชื่อลูกค้า</a></th>
    <th scope="col"><a href="#">รายการแจ้งซักรีด</a></th>
    <th scope="col"><a href="#">สั่งซื้อสินค้า</a></th>
  </tr>
</table>
<p align="center">&nbsp;</p>
<p align="center"><font size="3">&lt;&lt; 
  <a  href="managebill.php">เรียกดูใบสั่งซื้อสินค้าในฐานข้อมูล</a> &gt;&gt;
&lt;&lt; <a href="index.php">เพิ่มใบสั่งซื้อสินค้าลงฐานข้อมูล</a> &gt;&gt;</font></p>

<!-- ส่วนหัวของฟอร์มที่เป็นการบอกว่าจะให้ไปหน้าไหน หลังกดปุ่ม Submit -->
<form action="OrderAdd.php" method="post" onSubmit="return checkform(this);">
  <p>&nbsp;</p>
  <table border="1" bordercolor="#000000" style="border-collapse: collapse" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFF" width="70%"  id="tbl">
    <tr> 
      <td bgcolor="#FFFF66"><p align="center"><font size="5" color="red"> 
      :: ใบสั่งซื้อสินค้า ::</font></p></td>
    </tr>
    <tr> 
      <td bgcolor="#FFFFFF"><font size="2"> 
      &nbsp;&nbsp;ชื่อ - นามสกุล ผู้ทำรายการ:</font><font size="2"><? $Employee_Name = 'วีรภัทร'; echo $Employee_Name; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  วันที่ออกบิล : </font></td>
    </tr>
   
     <tr> 
      <td bgcolor="#FFFFFF"><font size="2">&nbsp;&nbsp;ที่อยู่บริษัท : </font></td>
    </tr>
    <tr>
       <td bgcolor="#999999"><font size="2">&nbsp;&nbsp;ชื่อผู้จัดจำหน่าย :</font></td>
    </tr>
    <tr> 
      <td bgcolor="#FFCCFF"><p align="center"><font size="3"> 
          :: รายการสินค้าที่สั่งซื้อ ::</font></p></td>
    </tr>

    <tr> 
      <td bgcolor="#FFFFFF"><p align="left"><font size="2"> 
     		&nbsp;&nbsp;&nbsp;รหัสสินค้า:
          <input name="Product_ID[]" type="text" size="5" maxlength="10" id="Product_ID_0">
      </font><font size="2">&nbsp;&nbsp;ชื่อสินค้า :
            <input name="Product_Name[]" type="text" size="40" maxlength="200" id="Product_Name_0">
          &nbsp;&nbsp;จำนวนที่ซื้อ :
      <input name="Quantity[]" type="text" size="5" maxlength="5" id="Quantity_0">
          &nbsp;&nbsp;ราคาต่อหน่วย :
      <input name="Price[]" type="text" size="10" maxlength="10" id="Price_0">
    </font></p></td>
    </tr>
    <tr> 
      <td bgcolor="#FFCCFF"><p align="center"><font size="3"><a href="#" onClick="return addRow()">(เพิ่มรายการสินค้า)</a></font></p></td>
    </tr>

    <tr bgcolor="#FFFF66"> 
      <td colspan="2"> 
        <div align="center"> 
          <input type="submit" name="Submit" value="ส่งข้อมูล">
          &nbsp;
          <input type="reset" name="Reset" value="ลบข้อมูล">
        </div></td>
    </tr>
  </table>
  <br>
</form>
<center>
</center>
</body>
</html>





Tag : PHP, MySQL, HTML/CSS







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-07-15 18:29:11 By : Dongonline View : 1114 Reply : 20
 

 

No. 1



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


OrderAdd.php
Code (PHP)
<?php

mysql_connect("localhost", "root", "root");
mysql_select_db("ld2");
mysql_query("SET NAMES UTF8");

$Employee_ID = $_POST["Employee_Name"];
$Order_Date = 22;
$Status = 22;
$PriceTotal = 22;
$LaundryAddress = 'ที่อยู่ร้าน';
$Seller = 'บริษัทอะไรหว่า';

$insert1 = "insert into Order(Order_ID,Employee_ID,Order_Date,Status,PriceTotal,LaundryAddress,Seller) VALUES ('','$Employee_ID','$Order_Date','$Status','$PriceTotal','$LaundryAddress','$Seller')";
$result1 = mysql_query($insert1);


$Order_ID = mysql_insert_id();

for($i=0;$i<count($_POST["Product_ID"]);$i++)
{
	 $Product_ID = $_POST["Product_ID"][$i];
     $Product_Name = $_POST["Product_Name"][$i];
     $Quantity = $_POST["Quantity"][$i];
     $Price = $_POST["Price"][$i];

     // ทำการเก็บรายการสินค้าที่สั่งซื้อเอาไว้ในตาราง billdetails โดยใช้ bill_id เป็น Foreign Key ในการจับคู่กับใบสั่งซื้อสินค้าในภายหลัง
     $insert2 = "insert into orderdetail(OrderDetail_ID,Order_ID,Product_ID,Product_Name,Quantity,Price) VALUES ('',$Order_ID,'$Product_ID','$Product_Name','$Quantity','$Price')";
     $result2 = mysql_query($insert2);

	 mysql_close();
}

?>
<html>
<head>
<title>บันทึกการสั่งซื้อสินค้า</title>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">

</head>
<?php
echo $insert1;
echo $insert2;
?>
<body>
</body>
</html>







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-15 18:30:05 By : Dongonline
 


 

No. 2



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


ตอนที่มันฟ้องครับ

Code
insert into Order(Order_ID,Employee_ID,Order_Date,Status,PriceTotal,LaundryAddress,Seller) VALUES ('','','22','22','22','ที่อยู่ร้าน','บริษัทอะไรหว่า')insert into orderdetail(OrderDetail_ID,Order_ID,Product_ID,Product_Name,Quantity,Price) VALUES ('',0,'','','','')

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-15 18:30:35 By : Dongonline
 

 

No. 3



โพสกระทู้ ( 88 )
บทความ ( 0 )



สถานะออฟไลน์


ขอเดานะครับ ค่าที่เป็นตัวเลข ไม่มีตัว ' ครับ

ลองรึยังครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-15 18:58:13 By : gtblackhat
 


 

No. 4



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


ลองแล้วครับ ไม่ได้อ่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-15 20:08:27 By : Dongonline
 


 

No. 5



โพสกระทู้ ( 88 )
บทความ ( 0 )



สถานะออฟไลน์


insert ข้อมูล ชุดแรก เข้าไหมครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-15 20:12:28 By : gtblackhat
 


 

No. 6



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


ไม่เข้าอ่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-15 20:18:09 By : Dongonline
 


 

No. 7



โพสกระทู้ ( 88 )
บทความ ( 0 )



สถานะออฟไลน์


มันฟ้อง error ว่า ข้อมูลไม่ math อะไรสักอย่าง รึป่าวครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-15 20:19:58 By : gtblackhat
 


 

No. 8



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


ใช่ครับ ข้อมูล จาก order ไม่เข้ามาใน orderadd อ่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-15 20:28:01 By : Dongonline
 


 

No. 9



โพสกระทู้ ( 88 )
บทความ ( 0 )



สถานะออฟไลน์


รูปแบบข้อมูลที่กรอก ตรงกับ type ในฐานข้อมูลไหมครับ

ลองดูรูปแบบที่เรากรอก กับฐานข้อมูลเราครับผม ผมก็เคยเจอ นั่งแก้เป็นวันก็มี แค่รูปแบบไม่ตรงกันครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-15 20:35:56 By : gtblackhat
 


 

No. 10



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


ครับ เดี๋ยวผม ดูก่อน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-15 20:56:33 By : Dongonline
 


 

No. 11



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


order.php ส่งค่ามาให้กับ orderadd.php ได้แล้วครับ แต่ว่า sql เหมือนจะผิดอยู่อ่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-15 21:19:38 By : Dongonline
 


 

No. 12



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


ไม่ยอม auto ID ให้อ่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-15 22:34:03 By : Dongonline
 


 

No. 13



โพสกระทู้ ( 6 )
บทความ ( 0 )



สถานะออฟไลน์


ขอ DB ฐานข้อมูลด้วยครับ จะได้ทดสอบดูว่าเพราะอะไร
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-16 01:27:05 By : infinity8
 


 

No. 14



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


โครงสร้างตาราง `order`

Code
CREATE TABLE `order` (
`Order_ID` int(2) NOT NULL auto_increment,
`Employee_ID` varchar(10) NOT NULL,
`Order_Date` varchar(10) NOT NULL,
`Status` varchar(20) NOT NULL,
`PriceTotal` int(5) NOT NULL,
`LaundryAddress` varchar(50) NOT NULL,
`Seller` varchar(30) NOT NULL,
PRIMARY KEY (`Order_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;



โครงสร้างตาราง `orderdetail`

Code
CREATE TABLE `orderdetail` (
`OrderDetail_ID` int(4) NOT NULL auto_increment,
`Order_ID` int(4) NOT NULL,
`Product_ID` int(4) NOT NULL,
`Quantity` int(5) NOT NULL,
`Price` int(5) NOT NULL,
PRIMARY KEY (`OrderDetail_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-16 06:55:07 By : Dongonline
 


 

No. 15

Guest


ลองเปลี่ยนพวก $result2 = mysql_query($insert2); เป็นแบบนี้ดุ $result2 = mysql_query($insert2) or die (mysql_error());
เผื่อมันจะแสดงเออเรออะไรให้เห็นบ้างน่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-16 09:47:39 By : บังเอิญผ่านมาเห็น
 


 

No. 16



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


ได้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-16 15:12:32 By : Dongonline
 


 

No. 17



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


มันขึ้น you have an error in your SQL syntax; check the manual that corresponds to your MySQL server vertion for the right syntax to use near
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-16 15:22:58 By : Dongonline
 


 

No. 18



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Quote:
Order


คำสงวน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-16 17:13:07 By : mr.win
 


 

No. 19



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


จริงหรอครับ เฮอ เฮอ ไฟดับ เลยมาดูช้า
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-17 12:39:33 By : Dongonline
 


 

No. 20



โพสกระทู้ ( 151 )
บทความ ( 0 )



สถานะออฟไลน์


ได้แล้วครับ ขอบคุณครับ ติดคำสงวนนี่เอง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-17 13:13:24 By : Dongonline
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : เกิดปัญหาอะครับ คือว่า มัน insert ไม่ลงฐานข้อมูลอ่ะครับ ช่วยแก้ปัญหาให้ทีครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่