histats

Multiple Checkbox Input in CodeIgniter

Sometimes we need to insert multiple checkbox value to our database. We also need to combine our input values with our ID to get some table relations. For example, we will auto cluster students to class A and B. So, we need to have an input form there show students username, and optional value for class A or B.

If we press the submit button, it will process and save id_siswa and class to our new table. This table just for new relations. You know, if there is mandatori relations, so we need new table for save the relations.

Here is my simple code,

The controller

The view

I didn’t model file, because in this case, I pull student data from view. Its just for example case study, you can implement this code to your case.

Regrads, Sutriman