![]() |
Getting Multi-select data from a form - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Getting Multi-select data from a form (/showthread.php?tid=30390) |
Getting Multi-select data from a form - El Forum - 05-13-2010 [eluser]Bionicjoe[/eluser] My app has a multi-select field in one form, but when submitted to the db only one item is inserted. Any help is appreciated or point me to a good tutorial that shows creating a multiselect in CI from a db table and then adding the selections to the record table. View to make the multi-select Code: <tr><td>Location </td><td><?php echo form_multiselect('sitename', $siteoptions); ?></td></tr> Model to get the multiselect options from the db Code: function sitemultiselect() Controllers to add Code: function addoutage() Getting Multi-select data from a form - El Forum - 02-11-2011 [eluser]chazy (aldever calvo)[/eluser] hi.. may i ask how you solved the problem?.. i am having similar problem... but mine doesnt add anything at all. Getting Multi-select data from a form - El Forum - 02-11-2011 [eluser]defectivereject[/eluser] This was my solution. (Obviously going into your model to write the record back to your database!!!) Code: $data = array(); EDIT!! Oh and your form multiselect MUST be an array as follows Code: echo form_multiselect('input_name[]', $name, '', 'id="input_name"'); Getting Multi-select data from a form - El Forum - 02-11-2011 [eluser]chazy (aldever calvo)[/eluser] this was what i did... in this post: http://ellislab.com/forums/viewthread/180856/ i'll try using implode and explode... it'll be my first time to use those functions... ![]() Getting Multi-select data from a form - El Forum - 02-11-2011 [eluser]chazy (aldever calvo)[/eluser] thanks... i have the values now, but still not inserted... Code: A Database Error Occurred i followed your code and this is my model: Code: function AddSetMaterial($actNum, $actMat) for my controller: Code: function setmaterials() Code: <?php $actMat= $this->input->post('actMat[]');?> Getting Multi-select data from a form - El Forum - 02-11-2011 [eluser]chazy (aldever calvo)[/eluser] it's good if i changed the datatype of my db form integer to varchar... i hope theres another way of storing multiple int values because my goal is to insert the integer values per row of the column... Getting Multi-select data from a form - El Forum - 02-11-2011 [eluser]defectivereject[/eluser] try changing this line Code: 'ch_act_mat_mat_id' => implode(", ", $values), to this Code: 'ch_act_mat_mat_id' => implode(",", $values), The only thing i can think of as an INT field would accept any spaces as they aren't numbers Getting Multi-select data from a form - El Forum - 02-11-2011 [eluser]chazy (aldever calvo)[/eluser] done that... the problem doesn't change... the values could not be stored per row... ![]() Getting Multi-select data from a form - El Forum - 02-25-2011 [eluser]chazy (aldever calvo)[/eluser] solved in this thread http://ellislab.com/forums/viewthread/180856/ |