Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 错误地认为每个产品都有一个唯一的id。在这种情况下,它是“51040”,另一个id是商家id,并且每个提要都是相同的 $result = mysql_query("SELECT * from easy_contents"); while($row = my_Php_Mysql_Parsing - Fatal编程技术网

Php 错误地认为每个产品都有一个唯一的id。在这种情况下,它是“51040”,另一个id是商家id,并且每个提要都是相同的 $result = mysql_query("SELECT * from easy_contents"); while($row = my

Php 错误地认为每个产品都有一个唯一的id。在这种情况下,它是“51040”,另一个id是商家id,并且每个提要都是相同的 $result = mysql_query("SELECT * from easy_contents"); while($row = my,php,mysql,parsing,Php,Mysql,Parsing,错误地认为每个产品都有一个唯一的id。在这种情况下,它是“51040”,另一个id是商家id,并且每个提要都是相同的 $result = mysql_query("SELECT * from easy_contents"); while($row = mysql_fetch_array($result)) { $articles = array(); $easy_url = $row['rss_url']; $rawFeed = file_get_contents($easy_url); $

错误地认为每个产品都有一个唯一的id。在这种情况下,它是“51040”,另一个id是商家id,并且每个提要都是相同的
$result = mysql_query("SELECT * from easy_contents");
while($row = mysql_fetch_array($result))
{

$articles = array();
$easy_url = $row['rss_url'];

$rawFeed = file_get_contents($easy_url);
$xml = new SimpleXmlElement($rawFeed);


$channel = array();
$channel['title']       = $xml->channel->title;
$channel['link']        = $xml->channel->link;
$channel['description'] = $xml->channel->description;


foreach ($xml->channel->item as $item)
{
$article = array();
$article['title'] = $item->title;
$article['link'] = $item->link;
$article['description'] = (string) trim($item->description);

//strip out all the HTML tags
$item->description = str_replace('<table><tr><td width="110">','', $item->description);
$item->description = str_replace('</table>','', $item->description);
$item->description = str_replace('</td>','', $item->description);
$item->description = str_replace('<td>','', $item->description);
$item->description = str_replace('<br />','', $item->description);
$item->description = str_replace('<b>','', $item->description);
$item->description = str_replace('</b>','', $item->description);
$item->description = str_replace('</tr>','', $item->description);

//find all url encoded £ signs and find the string after
//string will be a price
preg_match_all('/&#xA3;([0-9.]+)/', $item->description, $results);
foreach ($results as $k => $v) {
}

//find the url encoded £ sign and append the price
$all = '&#xA3;'.$v[0];
$price_stripped = str_replace($all, '', $item->description);
$desc = preg_match('/&#xA3;([0-9.]+)/', $item->description);

//find the discount deleviry cost from the rss using the ~#&pound;NUMBER
//this is the discount
preg_match_all('/~#&pound;([0-9.]+)/', $item->description, $discount);
foreach ($discount as $d => $disc) {
str_replace("~#&pound;","", $disc[0]);
}

//find the remaining £PRICE and this is the delivery cost
//this is the delivery_cost
preg_match_all('/&pound;([0-9.]+)/', $item->description, $delivery_cost);
foreach ($delivery_cost as $del => $deliv) { 
}

 //find the | char and find the string after it
//this is the retailer_message
preg_match_all('/\|(.*?)\./',$item->description,$match);           
foreach ($match as $rel => $retail) { 
$retail[0] = str_replace("| ","", $retail[0]);
$retail_mess = str_replace(" On","On", $retail[0]);

 }   

 $total = $v[0] + $deliv[0] - $disc[0];

 $sql = "UPDATE easy_contents SET delivery_cost = '$deliv[0]', price = '$v[0]', total = '$total' WHERE rss_url = '$row[rss_url]' AND title = '$item->title' AND description = '$price_stripped' ";
 if(!$query = mysql_query($sql)) {
     echo "Error on line ".__LINE__.". ".mysql_error().".<br />\nQuery: ";
     exit;
 }
 echo "Query OK. <br />\nUpdated rows: ".mysql_affected_rows().".<br />\nQuery: ";
   }   
  }