|
 |
|
XML to Mysql by PHP สวัสดีครับ คือผมมีปัญหาอยู่อย่างหนึ่งอยากจะถามผู้รู้น่ะครับ |
|
 |
|
|
 |
 |
|
ผมหาวิธีได้แล้วครับ ประมาณนี้นะ
$path = "file"; //ชื่อโฟลเดอร์ที่ใช้เก็บไฟล์นะจ๊ะหมาน้อย
$dotfile = $_FILES['file']['type'];
if(is_uploaded_file($_FILES['file']['tmp_name']) && $file != "" && $dotfile == "application/x-xml")
{
copy($_FILES['file']['tmp_name'],"$path/".$_FILES['file']['name']);
$filenew = $_FILES['file']['name'];
$data = file_get_contents("file/$filenew");
preg_match_all('#<product>(.*)</product>#Us', $data, $records);
foreach ($records[1] as $record) {
preg_match_all('#<(.*)>(.*)</\1>#Us', $record, $values);
// $values[1] has the column names
// $values[2] has the values to insert
$sql = "insert into productstemp ("
. implode(', ', $values[1])
. ") values ('"
. implode("', '", $values[2])
. "')";
mysql_query($sql);
ถ้าใครอยากได้ตัวอย่างไฟล์ก็เมลืมาก้ได้ครับ เเด๋ยวจัดให้
|
 |
 |
 |
 |
Date :
7 ม.ค. 2550 05:07:57 |
By :
gutor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สวัสดีครับ
ถ้าผมอยากได้แบบว่า ดึงข้อมูลจาก MySql ขึ้นมด้วย Xml ล่ะครับ
มีโค้ดอย่างไรบ้างหรอครับ
ช่วยผมหน่อยนะ
|
 |
 |
 |
 |
Date :
2009-07-09 14:14:11 |
By :
โจ้ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|