This topic is locked

Table structure for dependent drop down

3/18/2021 2:07:51 AM
PHPRunner General questions
B
bipingaur author

My application has two tables training and competency. A competency can have many trainings linked to it and a training can have many competency that it covers. A many to many relationship

I want to be able to create a table where I manage this relation. The table for this is below.

competency_training with fields - ct_id, ct_competency_id and ct_training_id.

I am trying to create an add page via which I would be able to do this

  1. Select a competency (drop down using competency table) ct_id
  2. On selecting this the value for checkbox list ct_training_id is auto filled. This I am able to do via where cause
  3. A separate checkbox list created from ALL the values of table training to be able to select more values trainings.trainings_id
  4. Able to add multiple values to the table ct_id
    My SQL Query is below



SELECT

competency_training.ct_id,

competency_training.ct_competency_id,

competency_training.ct_training_id,

competency.competency_id,

trainings.trainings_id,

competency.competency_name,

trainings.trainings_name

FROM competency_training

INNER JOIN competency ON competency_training.ct_competency_id = competency.competency_id

INNER JOIN trainings ON competency_training.ct_training_id = trainings.trainings_id

[media]https://ibb.co/QQw6ztK[/media]

Sergey Kornilov admin 3/18/2021
B
bipingaur author 3/18/2021



Check this for inspiration:

https://xlinesoft.com/blog/2011/02/28/how-to-setup-many-to-many-relationships/



Thank you, however none of the links are working at the bottom

Sergey Kornilov admin 3/18/2021

Yes, this is an old tutorial so no demo or project, or video is available. But the approach to handle many-to-many relationships is still the same.

B
bipingaur author 3/18/2021



Yes, this is an old tutorial so no demo or project, or video is available. But the approach to handle many-to-many relationships is still the same.


Thank you, I could find the video on youtube and was able to get it to work. However it can still add only one piece of data at a time.

I want to create a grid add like feature, with the already entered data being visible and non updatable.

Please see the image below to see what I mean
https://ibb.co/QQw6ztK