I have an XML feed which updates/ inserts data into a MySQL database using a cron job. This works fine up to the point when an item of data in the feed is no longer updated but simply deleted. This data is not deleted from the DB and is still available which is what I am trying to prevent . I have the following code so far.
//////////////////// DELETE ITEMS REMOVED FROM FEED //////////////////////////
// LOOP THROUGH ITEM ID'S CURRENTLY IN FEED
foreach($xml->property as $property) :
$propertyid = $property->id;
$removed .= sprintf(
$removed = rtrim($removed, ',') ;
// SELECT ITEMS IN DATABASE THAT ARE NOT CONTAINED IN CURRENT FEED
$query = "SELECT * FROM `feed` WHERE `ref` NOT IN ('$removed')";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)):
$ref1 = $row['ref'];
echo "<br />Affected Reference(s): " . $ref1 ;
The query prints like this: SELECT * FROM
ref NOT IN (' 12345, 33102, 33186, 33210, 37701')
I am not sure about the use of NOT IN ??
What I need the query to do is select the ref that are not contained in the feed so that I can delete them.
Help and advice please.