This topic is locked
[SOLVED]

 One to many

12/3/2011 7:05:27 AM
PHPRunner General questions
G
giorgiots author

This is my situation: I have 2 tables, on a one to many relatioship.

The master table, "tbl1" has the fields "id", "code", "date"

The child table , "tbl2" has the fileds "idcld", "code", "date1" and "date2".
The key field to the relationship is "code".
I have choosen to show the child page when I'm on the edit page of the master table. What I'm trying to do is when I press the inline edit button on a specific child record, to update the field "date2" of that specific child to the value oh "date" of the master table.
Any ideas how to achieve that?
Thanks in advance
Giorgio

C
cgphp 12/4/2011

In the "Edit page: Before process" event of the master table (tbl1), enter this code:

$_SESSION['current_record'] = $_GET['editid1'];



In the "Process record values" event of edit page of the child table (tbl2), enter this code:

$rs = CustomQuery("SELECT date FROM tbl1 WHERE id=".$_SESSION['current_record']." LIMIT 1");

$record = db_fetch_array($rs);

$values['date2'] = $record['date'];



In the "List page: Before process" event of the master table (tbl1), enter this code:

unset($_SESSION['current_record']);
G
giorgiots author 12/4/2011

I see what you're doing!
Thank you!