• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple Checkbox Saving in MySQL?

#1
[eluser]dhall[/eluser]
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:
Code:
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.

#2
[eluser]heavyman1[/eluser]
Code:
$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.

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

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

#3
[eluser]dhall[/eluser]
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.

#4
[eluser]heavyman1[/eluser]
I've never tried. But I believe you can use [].

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.