new feed or curl data fetch

0
430

<?php
$link = mysql_connect(‘localhost’,’root’,’password’);
mysql_select_db(‘db_name’,$link);

for($j=1;$j<=2000;$j++)
{
$xml=simplexml_load_file(“http://www.nhs.uk/NHSChoices/shared/RSSFeedGenerator/RSSFeed.aspx?site=News&topic=&page=$j”);$array = json_decode(json_encode($xml), true);
$i=0;
//echo ‘<pre>’;
//print_r($array[‘channel’][‘item’] ); exit;

foreach ($array[‘channel’][‘item’] as $val){

$description= $xml->channel->item[$i]->description;
$title=$val[‘title’];
$link=$val[‘link’];
$pubDate=date(“d M Y h:i:s”,strtotime($val[‘pubDate’]));
$description=html_entity_decode($description);
$num=mysql_num_rows(mysql_query (“SELECT *
FROM `tbl_news` where NewsLink ='”.$link.”‘”));
if($num==0)
{
mysql_query(“insert    into
‘news_title’    = $title,
‘image’         = ”,
‘news_paper’     = ”,
‘news_desc’     = $description,
‘news_status’    =’Active’,
‘updatedOn’     = $pubDate,
‘deletedOn’     = ‘0’,
‘news_date’     =$pubDate,
‘NewsLink’     =$link”
);
//$this->news_model->safe_insert(‘tbl_news’,$posted_data,FALSE);
}
$i++;
}

}

/* End of file pages.php */

?>