This topic is locked

Detail Table Values to Master Table Field

8/20/2019 7:13:01 AM
PHPRunner General questions
H
harveyspecter author

Hello,
MasterTable:
ID

Did (int 11)

Names

....
DetailTable:

ID

Did (int 11)

Name

.....
MasterTable and DetailTable are in master-detail (Did-Did)
When I add detail values in mastertable's add page I add atleast 2 or 3 Name to details. Something like this:
Master Table's Add Page

------------------------
Select Did: 2
Detail Table InlineAdd
ID Did Name

1 2 Name1

2 2 Name2

3 2 Name3
After i "Save" it i want it to copy all that names and put it as a text to MasterTables "Names" field something like "Name1, Name2, Name3"
Can anyone help on it?
Thanks alot!!

N
Nir Frumer 8/20/2019



Hello,
MasterTable:
ID

Did (int 11)

Names

....
DetailTable:

ID

Did (int 11)

Name

.....
MasterTable and DetailTable are in master-detail (Did-Did)
When I add detail values in mastertable's add page I add atleast 2 or 3 Name to details. Something like this:
Master Table's Add Page

------------------------
Select Did: 2
Detail Table InlineAdd
ID Did Name

1 2 Name1

2 2 Name2

3 2 Name3
After i "Save" it i want it to copy all that names and put it as a text to MasterTables "Names" field something like "Name1, Name2, Name3"
Can anyone help on it?
Thanks alot!!



assuming that you use mysql..

in the after add of the detail table add

$strSql="update master set names=names".$values['name']." where id=".$values['id'];

db_exec($strSql);
good luck

M
mersintarim 8/21/2019

hi,

before save
loop for details value and concat , next update this value to master use $_SESSION[$strTableName."_masterkey"]

H
harveyspecter author 8/22/2019



assuming that you use mysql..

in the after add of the detail table add

$strSql="update master set names=names".$values['name']." where id=".$values['id'];

db_exec($strSql);
good luck


Thanks for idea. But still it only puts 1 name to the names field. I need the all names with same ID.