<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once ('../includes/connect.php');
try {
$filter = $db->query("SELECT * FROM procesory");
$check = $filter->rowCount();
echo $check.'<br />';
while($c = $filter->fetch()){
$source = file_get_contents($c['pURLMorele']);
$doc = new DomDocument();
$file = @$doc->loadHTML($source);
$rows = $doc->getElementsByTagName('span');
foreach ($rows as $row) {
if($row->getAttribute('class') == 'price') {
echo $c['ID'].' - ';
echo $row->nodeValue.' -- OK!<br />';
$id = $c['ID'];
$price = $row->nodeValue;
$update = $db->prepare("UPDATE procesory SET pPrice=:price WHERE ID=:id");
$update->bindValue(':price', $price);
$update->bindValue(':id', $id);
$update->execute();
}
}
}
}
catch (PDOException $e) {
echo 'Something went wrong!<br>'.$e->getMessage();
die();
}
?>
I think that's better, but still.. All the time ID from 2 to 4 and i need from 1 to 4 :/