Hello:
I'm trying to keep track of some information for historical purposes. I'm inserting new recoreds using REPLACE INTO and if its a new record or if the recored has changed then INSERT INTO the history table. What I'm finding is that it will insert information to the history table even though no information has changed. I only want to insert recoreds into the history table if its new recored of if the orginal information has changed.
Below is part of my code, any help would be great!
$Query = "REPLACE INTO `Table` ( `CoID` , `First` , `Last` ) VALUES ('$CoID', '$First', '$Last' )";
$Result = @mysql_query($Query, $Con);
if ((mysql_affected_rows() == 1) || (mysql_affected_rows() == 2)) {
// INSERT FOR HISTORY IF NEW OR UPDATED.
$Query2 = "INSERT INTO `Table_History` ( `CoID` , `First` , `Last`) VALUES ('$CoID', '$First', '$Last')";
$Result2 = @mysql_query($Query2, $Con);
}