I'm trying to use the event "Save old data record in another table"
I have a table called "tbl_EPR_MSGT" where I'm storing performance reports for employees. When a supervisor edits it I want to have an event BEFORE save that puts a copy of the old record into another table called "tbl_archived_EPR_MSGT" ... I decided to just start with two fields [user_ID] and [user_rank] to see if I could get it to work and then I could add in the rest of the fields I want.
I started with this basic code from phpRunner
//** Save old data record in another table ****
global $conn,$strTableName;
$strSQLSave = "INSERT INTO AnotherTable (Field1, Field2) SELECT Field1, Field2 FROM ".$strTableName." where ".$where;
db_exec($strSQLSave,$conn);
- after reading through the forum and trying various changes I ended up with the code below (so far nothing has worked...)
//** Save old data record in another table ****
global $conn,$strTableName;
$strSQLSave = "INSERT INTO tbl_archived_EPR_MSGT ([user_ID],[user_rank]) values ('";
$strSQLSave .=$values["user_ID"]."','";
$strSQLSave .=$values["user_rank"];
$strSQLSave .="')";
echo $strSQLSave;
db_exec($strSQLSave,$conn);