This topic is locked

saving edited record to another table

4/16/2007 9:40:33 AM
PHPRunner General questions
M
mrpeeble author

I am working with a demo of phprunner. having some difficulty saving a record to an audit table everytime the record is edited in the main table.
my main table is mto_main. my audit table is mto_audit. whenever i edit a record in mto_main i want to create a new record in mto_audit. 3 of my field names are: userID, InquiryDate and MemberID. The structure of both tables is the same. I have tried the following:
function BeforeEdit(&$values, $where)

{
//** Insert a record into another table ****

global $conn;

$strSQLInsert = "insert into mto_audit (userID, InquiryDate, MemberID) values (userID, InquiryDate, MemberID)";

db_exec($strSQLInsert,$conn);
return true;
}
any help would be appreciated,
thank you

Alexey admin 4/16/2007

Hi,
use $values array to obtain user entered values.

Here is the code:

function BeforeEdit(&$values, $where)

{
//** Insert a record into another table ****

global $conn;

$strSQLInsert = "insert into mto_audit (userID, InquiryDate, MemberID) values ('".$values["userID"]."', '".$values["InquiryDate"]."', '".$values["MemberID"]."')";

db_exec($strSQLInsert,$conn);
return true;
}

M
mrpeeble author 4/16/2007

Hi,

use $values array to obtain user entered values.

Here is the code:

M
mrpeeble author 4/16/2007

yup, that fixed it, thanks!

Hi,

use $values array to obtain user entered values.

Here is the code: