This topic is locked
[SOLVED]

 Update data in CHILD table

6/30/2010 11:23:31 AM
PHPRunner General questions
B
bangke author

Hi
I have two tables, Master and Detail.
master

=========================

PARTNUMBER PART_NAME

=========================

1111111111 KEYBOARD

2222222222 MOUSE
detail

=========================

PARTNUMBER PART_NAME

=========================

1111111111
In the DETAIL TABLE i use lookup fuction to lookup PARTNUMBER in the MASTER TABLE.

i want, for example, when i save the child table, the field PART_NAME updated to KEYBOARD..
How configure it in PHPRUNNER add event?

Thanks.

A
ann 7/1/2010

Hi,
use After record added event on the Events tab of Master table. Here is the sample code:

$sql = "UPDATE child_table SET PART_NAME='".$values["PART_NAME"]."' WHERE PARTNUMBER=" . $values["PARTNUMBER"];

CustomQuery($sql);
B
bangke author 7/1/2010



Hi,
use After record added event on the Events tab of Master table. Here is the sample code:

$sql = "UPDATE child_table SET PART_NAME='".$values["PART_NAME"]."' WHERE PARTNUMBER=" . $values["PARTNUMBER"];

CustomQuery($sql);



Thank Ann but in this example i'm not working with MASTER TABLE but CHILD TABLE.

I mean when i input a part number on PART_NUMBER field on child table, i want the PART_NAME field updated.

A
ann 7/2/2010

Hi,
then just replace child_name with master_name in the query and use corresponding event of the Child table.

romaldus 7/13/2010



Thank Ann but in this example i'm not working with MASTER TABLE but CHILD TABLE.

I mean when i input a part number on PART_NUMBER field on child table, i want the PART_NAME field updated.


on AFTER RECORD ADDED an AFTER RECORD UPDATED events just add:

$sql = "UPDATE child_table SET part_name =(SELECT part_name FROM master_table WHERE Partnumber=Partnumber)";

CustomQuery($sql);
B
bangke author 7/13/2010
$sql = "UPDATE child_table SET part_name =(SELECT part_name FROM master_table WHERE Partnumber=Partnumber)";

CustomQuery($sql);


thank you very much romaldus. it works now <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=51140&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />

B
bangke author 7/13/2010
$sql = "UPDATE child_table SET part_name =(SELECT part_name FROM master_table WHERE Partnumber=Partnumber)";

CustomQuery($sql);


thank you very much romaldus. it works now <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=51141&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />