Quick background info: of the three database tables that are relevant for this question, one holds devices info (d.id
, d.name
), the second one holds accessories for the devices in the first table (a.id
, a.name
) and the third table handles relations between the first two (d.id
, a.id
).
By selecting one of the available devices from a drop-down box, a list of all accessories is being displayed, each with a checkbox which is either checked or not, based on the data in the relations table.
And this brings us to my problem: I am not sure what is the most efficient way of checking which checkboxes were changed after the form has been submitted, as well as what the most efficient way of querying the database would be, since both INSERT
s and DELETE
s might be required for the same submitted form (i.e. a users un-checks a checked checkbox and checks an un-checked one -- whoa, that phrase should be a diction exercise -- before submitting).
By the way, I'm not hell bent on using checkboxes, but I figured it would be a clean way to handle this. Any suggestions and proof-of-concept code would be more than appreciated !
Thank you all in advance !