This topic is locked

Master Detail - Edit Detail Unique Dropdown Menu

6/16/2016 12:20:51 PM
PHPRunner General questions
H
Hopper author

I have a table that contains departments. This table is used to populate a dropdown menu for a detail record. I would like for the dropdown menu to only populate with departments that are not already assigned to the master record.
Department Table
Dept1

Dept2

Dept3

Dept4

Dept5
Detail Table

masterID id department

1 1 Dept1

1 2 Dept2

1 3 Dept5

2 4 Dept5

3 5 Dept2

3 6 Dept1
Given the above the user would have the following departments list in dropdown when editing detail record for corresponding master record.
masterID 1

Dept3

Dept4
masterID 2

Dept1

Dept2

Dept3

Dept5
masterID 3

Dept3

Dept4

Dept5
Thanks in advance for any assistance!

Sergey Kornilov admin 6/16/2016

This can be done but might be tricky. You need to specify a WHERE clause for this dropdown box using NOT IN operand.
You can trying something along the lines of

" NOT IN (select department from `Details Table` where masterID = " . $_SESSION["Details Table_masterkey1"] . ") "