Please can anyone shed any light on why this code does not work correctly
It reports ‘Record updated successfully’ but does not insert any data into the quantity column.
I am presuming that it has something to do with the WHERE item = “.$item.” as when I remove it it works but only inserts the quantity from the very last xml record into all fields.
<CREATED value="Mon Jan 27 21:48:22 UTC 2020">
<PRODUCT ITEM="13726">
<QUANTITY>4467</QUANTITY>
</PRODUCT>
</CREATED>
[code]foreach ($xml->CREATED->PRODUCT as $row) {
print_r($row);
$item = mysqli_escape_string($conn, $row->attributes()[‘ITEM’]);
$quantity = mysqli_escape_string($conn, $row->QUANTITY);
  $sql2 = "UPDATE tbl_temp_products SET quantity = ".$quantity." WHERE item = ".$item."";
 }
if (mysqli_query($conn, $sql2)) {
echo “Record updated successfully”;
} else {
echo "Error updating record: " . mysqli_error($conn);
}
[/code]
 
      
     every record in the database is being updated with the final value in the xml feed and not each individual products quantity from the respective line in the feed (if that makes sense).
 every record in the database is being updated with the final value in the xml feed and not each individual products quantity from the respective line in the feed (if that makes sense).