vendredi 26 juin 2020

Dynamic checkboxes from one table and update a joining table

I am a total beginner and after long searches to no avail I have come to ask you for some help. I have 3 tables. Tutors, Availability and Periods. The periods table (ID, Name) contains a rows - Mornings, Afternoon, Evenings, Weekends The Availability table has FKs pointing to Users (ID) and Periods (ID)

The Periods table is displayed as a list of checkboxes so the Tutor can select which ones he/she wants.

I want to update the Availability table with the User ID and selected Period(s) row by row.

Also when I display the list of periods how do I show which ones the tutor selected?

And finally, how to I update the Availability table to store only the checked periods.

If the Availability table has the following:

ID User ID, Period ID  
1       1        1  
2       1        4

So User 1 is available for Mornings and weekends. If User 1 then de-selects period 1 how can I update the availability table to remove the correct row?

I hope this makes sense and I thank you in advance.




Aucun commentaire:

Enregistrer un commentaire