$data = [];
while ($z->name === 'offer') {
...
$data[] = '("'.$id.'","'.htmlspecialchars(urldecode($url)).'","'.$today.'",'.(int)$price.')';
if (count($data) > 99) {
$sql = 'INSERT INTO `products` (`id`,`url`,`date`,`price`) VALUES '
. implode(',', $data)
. 'ON DUPLICATE KEY UPDATE `url` = VALUES(`url`), `price` = VALUES(`price`)';
mysqli_query($link6,$sql);
$data = [];
}
...
}
if (count($data) > 0) {
$sql = 'INSERT INTO `products` (`id`,`url`,`date`,`price`) VALUES '
. implode(',', $data)
. 'ON DUPLICATE KEY UPDATE `url` = VALUES(`url`), `price` = VALUES(`price`)';
mysqli_query($link6,$sql);
}