I am trying to read in an XML file and compare it with fields in an existing database.
If the identifier in the database does not exist in the XML file, then the entire row corresponding to the identifier is no longer valid and will be deleted.
To do this, I read in each line of XML from beginning to end in a while statement.
As a first step, I try to do a simple mapping and echo if it finds an identifier in a database that does not exist in XML.
I know that there are several identifiers in the database that do not exist in XML, but the following code does not display them.
I have three questions: firstly, how can I display the Id that I pulled from the database, and secondly, why this code does not detect identifiers that are not in XML?
The last question: I am completely wrong about this, and there is a better way to do this!
$sql_result = mysql_query("SELECT id FROM `list` WHERE id = $id") or die(mysql_error()); if($sql_result) { // echo $id . " Id exists " . $sql_result["id"] . "\n"; } else { echo "Id no longer exists" . $id . "\n"; }
source share