#!/usr/bin/php $descr : $temp\n"); mysql_query($query); $temp_exists[] = "$id $fulloid"; } $temp_exists[] = "$id $temp_oid"; } } } } ## Delete removed sensors $sql = "SELECT * FROM temperature AS T, devices AS D WHERE T.temp_host = D.device_id AND D.status = '1'"; $query = mysql_query($sql); while ($sensor = mysql_fetch_array($query)) { unset($exists); $i = 0; while ($i < count($temp_exists) && !$exists) { $thistemp = $sensor['temp_host'] . " " . $sensor['temp_oid']; if ($temp_exists[$i] == $thistemp) { $exists = 1; } $i++; } if(!$exists) { echo("Deleting...\n"); mysql_query("DELETE FROM temperature WHERE temp_id = '" . $sensor['temp_id'] . "'"); } } ?>