|
 |
|
เขียนโค้ดอ่าน XML แล้ว Insert ข้อมูลลงในตารางแล้วมัน Insert แค่ข้อมูลชุดสุดท้ายอ่ะครับ |
|
 |
|
|
 |
 |
|
คือผมต้องการให้อ่าน XML --> สร้างตารางใน DB --> Insert ข้อมูลที่ได้จาก XML ลงในตาราง
แล้วผมติดปัญหาอ่ะครับ ปัญหาคือมันแทรกข้อมูลลงในตารางแค่ชุดสุดท้ายอะครับ ตามตัวที่เน้นแดง
นอกนั้นมันไม่ได้แอดลงตารางอ่ะครับ คือต้องเพิ่มโค้ดตรงไหนถึงจะทำให้มัน insert ข้อมูลทั้งหมดลงในตารางได้หรอครับ
ขอบคุณมากๆ เลยครับ
ข้อมูลที่อ่านจาก XML
hotel00113,http://im.ido24.com/hotel/bangkok/pathumwan_princess_hotel/images/hotelshow.jpg,โรงแรม ปทุมวัน ปริ๊นเซส,444 ถนนพญาไท ปทุมวัน กรุงเทพฯ 10330,http://ido24.org/siambooking.in.th/bangkok/pathumwan_princess_hotel,สยามสแควร์,4,5295
hotel03143,http://im.ido24.com/hotel/bangkok/hotel_muse_bangkok_langsuan/images/hotelshow.jpg,โฮเต็ล มิวส์ แบงค์คอค หลังสวน ,55/555 ซอยหลังสวน ถนนเพลินจิต ลุมพินี ปทุมวัน กรุงเทพ 10330,http://ido24.org/siambooking.in.th/bangkok/hotel_muse_bangkok_langsuan,เพลินจิต - ชิดลม,5,5715
hotel00051,http://im.ido24.com/hotel/bangkok/the_eugenia/images/hotelshow.jpg,เดอะ ยูจีเนีย โดย เลอบัว,267 ซอยสุขุมวิท 31 ถนนสุขุมวิท กรุงเทพฯ 10110 ,http://ido24.org/siambooking.in.th/bangkok/the_eugenia,สุขุมวิท,3,6595
Tag : PHP, MySQL

|
ประวัติการแก้ไข 2011-10-02 15:33:42 2011-10-02 18:54:30 2011-10-03 01:31:09 2011-10-03 11:40:23 2011-10-03 12:22:54
|
 |
 |
 |
 |
Date :
2011-10-02 15:12:04 |
By :
zspnix |
View :
1537 |
Reply :
7 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
mysql_qury("....") or dir(mysql_error());
จะได้รู้ว่า errorเพราะอะไร
|
 |
 |
 |
 |
Date :
2011-10-02 18:40:54 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ ผมลองแล้วมันไม่เออเร่อครับ แต่เหมือนว่าผมแทนตัวแปรผิด
เลยไม่มีข้อมูลให้ Insert อ่ะครับ ผมลองแทนแบบว่า
$hid = ".$child->hid." ; ก็ไม่ได้อ่ะครับ ไม่ทราบว่าตัว ".$child->hid." ที่เอาไว้อ่าน XML จะสามารถแทนได้ด้วยอะไรบ้างหรอครับ
ขอบคุณครับผม
|
 |
 |
 |
 |
Date :
2011-10-02 18:46:46 |
By :
zspnix |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
mysql_query("CREATE TABLE $prv (
hid varchar(7) ,
hpage_image varchar(100) ,
hname varchar(100) ,
haddress varchar(200) ,
hpage varchar(100) ,
harea varchar(50) ,
hstar varchar(3) ,
hrate varchar(6) ,
);") or die(mysql_error());
mysql_query("INSERT INTO $prv (
hid , hpage_image , hname , haddress , hpage , harea , hstar , hrate )
values ( '".$child->hid."' , '".$child->hpage_image."' , '".$child->hname."' , '".$child->haddress."' , '".$child->hpage."' , '".$child->harea."' , '".$child->hstar."' , '".$child->hrate."');") or die(mysql_error());
|
 |
 |
 |
 |
Date :
2011-10-02 22:13:29 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
UPDATE: ตอนนี้มันแทรกข้อมูลในตารางได้แล้วครับ แต่ว่ามันแทรกแค่ชุดเดียวอะครับ คือชุดสุดท้าย
มีวิธีทำยังไงให้มันแทรกได้ทั้งหมดหรอครับ แบบว่าตอนนี้มันแทรกข้อมูลในตารางแค่ชุดสุดท้ายแบบนี้อ่ะครับ
Code
hotel00113,http://im.ido24.com/hotel/bangkok/pathumwan_princess_hotel/images/hotelshow.jpg,โรงแรม ปทุมวัน ปริ๊นเซส,444 ถนนพญาไท ปทุมวัน กรุงเทพฯ 10330,http://ido24.org/siambooking.in.th/bangkok/pathumwan_princess_hotel,สยามสแควร์,4,5295
hotel03143,http://im.ido24.com/hotel/bangkok/hotel_muse_bangkok_langsuan/images/hotelshow.jpg,โฮเต็ล มิวส์ แบงค์คอค หลังสวน ,55/555 ซอยหลังสวน ถนนเพลินจิต ลุมพินี ปทุมวัน กรุงเทพ 10330,http://ido24.org/siambooking.in.th/bangkok/hotel_muse_bangkok_langsuan,เพลินจิต - ชิดลม,5,5715
hotel00051,http://im.ido24.com/hotel/bangkok/the_eugenia/images/hotelshow.jpg,เดอะ ยูจีเนีย โดย เลอบัว,267 ซอยสุขุมวิท 31 ถนนสุขุมวิท กรุงเทพฯ 10110 ,http://ido24.org/siambooking.in.th/bangkok/the_eugenia,สุขุมวิท,3,6595
ตัวที่เน้นสีแดงเลยครับ
|
 |
 |
 |
 |
Date :
2011-10-03 01:24:04 |
By :
zspnix |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โค๊ด insert มันไม่ได้อยู่ใน loop for นิิครับ มันก็เลย insert แถวสุดท้าย ลองเอาคำตอบผมไปคิดดูนะว่าต้องทำยังไง
|
 |
 |
 |
 |
Date :
2011-10-03 02:29:52 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|