I have a form that is made up of lots of radio buttons and check-boxes, and I was wondering what the best way to save their values to the database is. There are a few things to take into account.
All the the radio/checkboxes have different names. I've already created a new table with a column for each radio/checkbox, 30 new columns in total. I was advised this way is better than storing multiple checkboxes values in a single column.
I am working on a system based on the MVC Model, and this is the code I have in the controller file to send the radio/checkbox value to the database
if (isset($this->request->post['buss_type'])) { $this->data['buss_type'] = $this->request->post['buss_type']; } else { $this->data['buss_type'] = ''; }I was wondering if I am forced to duplicate the previous code for my 30 radio/checkboxes, or is there's a simpler way in which I could put all radio/checkboxes together?
I'd appreciate it very much if you are really specific since I just started learning PHP.
EDIT DEMO ADDED Click on "Corporate Account" to see the form.