This topic is locked

Insert multiple records into a detail table with data from another table

8/25/2016 10:05:42 AM
PHPRunner General questions
K
kdgsv author

Hallo,
I´m struggeling with finding a solution for my project and I hope someone can guide me in the right direction an help me with coding.
I have the following tables:
Master table: tb_unit:
ID, unit_name, assey_1, assey_2, assey_3
1, name1, 111, 222, 333
Detail table: tbl_spare_parts
ID unit_identifyer spare_part_number
unit_identifyer is linked to id file of tbl_unit
there are also for every assey a table where the spare part numbers are defined for the different asseys.
tbl_assy1:
id assey_nr spare_part_number
1, 111, 58796
tbl_assy2:
id assey_nr spare_part_number
1, 222, 56789
tbl_assy1:
id assey_nr spare_part_number
1, 333, 32665
What I´m looking for is the following:
I want to add a new unit with tbl_unit add page. Ther will be always added the name and the assey numbers.

After I safe the new unit in tbl_unit the following should happen:
The spare part numbers from the different assey tables should be written into tbl_spare_parts. Important is that the unit_identifyer in this table is equal to the ID field of tbl_unit.
At the moment I don`t know where to start and which event I have to use.
Any help would be appreciated.
Thank you.
Matthias

romaldus 8/25/2016



Hallo,
I´m struggeling with finding a solution for my project and I hope someone can guide me in the right direction an help me with coding.
I have the following tables:
Master table: tb_unit:
ID, unit_name, assey_1, assey_2, assey_3
1, name1, 111, 222, 333
Detail table: tbl_spare_parts
ID unit_identifyer spare_part_number
unit_identifyer is linked to id file of tbl_unit
there are also for every assey a table where the spare part numbers are defined for the different asseys.
tbl_assy1:
id assey_nr spare_part_number
1, 111, 58796
tbl_assy2:
id assey_nr spare_part_number
1, 222, 56789
tbl_assy1:
id assey_nr spare_part_number
1, 333, 32665
What I´m looking for is the following:
I want to add a new unit with tbl_unit add page. Ther will be always added the name and the assey numbers.

After I safe the new unit in tbl_unit the following should happen:
The spare part numbers from the different assey tables should be written into tbl_spare_parts. Important is that the unit_identifyer in this table is equal to the ID field of tbl_unit.
At the moment I don`t know where to start and which event I have to use.
Any help would be appreciated.
Thank you.
Matthias


why do you store spare parts in more than one table? tbl_assy1, tbl_assy1, ....

K
kdgsv author 8/26/2016



why do you store spare parts in more than one table? tbl_assy1, tbl_assy1, ....


In these tables I store the different asseys. but I want to have one spare part list.
I still copied all spar parts of the units I have setup in my database manually together in one list and it`S working fine.
But every time I´ve to setup a new unit I have to copy manually the new parts with the new identifiyer into the spare part list.
An thats the reason why I´l look for a solution to do this automatically

K
kdgsv author 9/16/2016

Thank you for helping me on this.
KR
Matthias