Welcome Guest, Not a member yet? Register   Sign In
Multiple Checkbox Saving in MySQL?

I have an array that I pass from Controller to View to create a list of checkbox options for the User.
Here is the view:
echo form_label('Secondary Activities:').br(1);
  foreach($all_activities as $row) {
    echo "<p class='activity_select'>";
    echo form_checkbox($row->act_type_id).nbs(2);
    echo form_label($row->act_type_name);
    echo "</p>";

How do I take the selected options and save them into a database table to then allow for reposting once saved?
Sorry, I am new to all this stuff.

$data = array(
    'name'        => 'newsletter',
    'id'          => 'newsletter',
    'value'       => 'accept',
    'checked'     => TRUE,
    'style'       => 'margin:10px',

echo form_checkbox($data);

You can use this to give each field name. So you can get the its value, by submitting the form.

$newsletter = $this->input->post('newsletter');

try to echo the var $newsletter to make u easier to understand

My array consists of 17 options, which is dynamically generated when pulled from another database table. I don't think I could do that for all 17, and then having it be dynamic should the options change.

I've never tried. But I believe you can use [].

May be http://stackoverflow.com/questions/89022...lds-to-php will help

Theme © iAndrew 2016 - Forum software by © MyBB