Jump to content

DB Query with Checkbox group


loganbest

Recommended Posts

Hi,

 

I’m fairly new to OOPHP and CI so I had a quick question that could be an easy answer for some people.

 

I have a form right now with about 100 checkboxes all with the same name so they will submit as an array of numbers.

 

I also have a table named tag_restaurant_rel which is a relational table that is setup as InnoDB and both `restaurant_id` and `tag_id` are Foreign Keys relating to the corresponding columns in two other tables.

 

The form will be submitted with 1 restaurant_id and several tag_id’s.

 

In the tag_restaurant_rel table there is a record for each tag_id in the array all with the same restaurant_id from the form.

 

What I need to happen is for the form to be submitted and depending on the array of checkbox values the tag_restaurant_rel table will need to delete the records that are not in the array and create a new record for each tag_id in the array.

 

I’m mostly curious in the most efficient way to do this OOP and CI style.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.