This topic is locked

Auto copy/delete into another table

7/19/2008 2:54:48 AM
PHPRunner General questions
B
bosco author

Let's say I am adding, editing or deleting a data from table_1. I would like it to auto do the same thing to the related field in table_2 automatically.
For example, adding username=user1, data1=data, data2= data. Table_2 has the same field username and data1. I would like both of the data automatically copied to table_2 when it is added or edited from table_1. While when user1 is deleted from table_1, it will also delete user1 from table_2.
Is it possible to do that? Thanks.

J
Jane 7/21/2008

Hi,
use Before record added/updated/deleted events on the Events tab.

Here is a sample:

global $conn;

$str = "update TableName set field1='".$values["field1"]."' where RecordID=".$values["RecordID"];

db_exec($str,$conn);

B
bosco author 7/22/2008

Thanks