Hello !
I`m kinda new to it so I found this `job` very hard therefor I ask for Your help.
So, the thing is...
I have this XML file ( http://www.izishop.net/export.php )
which I need to open with php and read it, and insert some fields those fields on my MySQL database.
Well... i found some usefull informations which might help me here:
(http://www.thescripts.com/forum/thread2005.html)
Take that data
<?php
$data = "<?xml version=\"1.0\"?>
<sqldata>
<record><name>Pedro</name><eyecolor>brown</eyecolor></record>
<record><name>Muppy</name><eyecolor>blue</eyecolor></record>
</sqldata>";
?>
and get all the records into an array
<?php
preg_match_all('#<record>(.*)</record>#Us', $data, $records);
?>
then, for each record, get the respective values, and insert into sql
I am treating all values as strings (quoting them with ')
you might want to test the column names and do it differently
<?php
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 table ("
. implode(', ', $values[1])
. ") values ('"
. implode("', '", $values[2])
. "')";
echo $sql, '<br />'; ### or mysql_query($sql)
}
?>
This might go, but how do i set this data to be read from http://www.izishop.net/export.php ?
Afterward I need to update table if item already exist in my database.
I really don`t know how to do it, so any help will be appriciated.