I have a working code
<?php
$con = mysql_connect('localhost','test','test');
mysql_select_db('test',$con);
require_once("xml2json.php");
$testXmlFile = 'myxml.xml';
$xmlStringContents = file_get_contents($testXmlFile);
$jsonContents = "";
$jsonContents = xml2json::transformXmlStringToJson($xmlStringContents);
$obj =json_decode($jsonContents);
$rows = array();
foreach($obj->rss->channel->item as $item) {
$rows[] = "('".mysql_real_escape_string($item->title)."','".mysql_real_escape_string($item->description)."')";
}
$del_horoscope = "delete from jos_horoscope";
mysql_query($del_horoscope);
$query = "INSERT INTO `jos_horoscope` (`title`,`description`) VALUES ".implode(', ',$rows);
print_r ($query);
mysql_query($query);
// Do the query - do NOT show the output of mysql_error() in a production environment!
if (!mysql_query($query)) echo 'Oh no! Something went wrong with the query: '.mysql_error();
?>
But data is inserting twice with every run of this script. I am using delete statement to delete the data first before inserting new one.Can anyone please help me solve this twice problem. Here is teh screenshot of twice Data filled .http://i.imgur.com/7IM1mOE.png?1
NEW EDIT
Here is the INSERT QUERY echo http://pastebin.com/btZ7f85a The data is not duplicate.
Thanks in advance