[Help ASAP PLEASE] form_multiselect insert... - 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: [Help ASAP PLEASE] form_multiselect insert... (/showthread.php?tid=38549) Pages:
1
2
|
[Help ASAP PLEASE] form_multiselect insert... - El Forum - 02-10-2011 [eluser]chazy (aldever calvo)[/eluser] hello.. i need help regarding form_multiselect... whenever i tried to insert the multiple selected value into the db, it always gives me error: Code: A Database Error Occurred heres my model: Code: function AddSetMaterial($actNum, $actMat) view Code: <table> controller Code: function setmaterials() PLease help me... school deadline is almost up... T.T [Help ASAP PLEASE] form_multiselect insert... - El Forum - 02-11-2011 [eluser]Roy MJ[/eluser] Ive done this multiple select box using implode and explode functions. U join together all the selected values separated by a comma or something and u can use the explode function to separate the imploded values too. Its much simpler than using arrays and stuff. Very simple and effective.. [Help ASAP PLEASE] form_multiselect insert... - El Forum - 02-11-2011 [eluser]Ochetski[/eluser] Your error is that "$actMat.'[]';" is not a valid value for a int (as defined on DB). You should change the collumn type on DB to varchar or text. @Roy's idea is also great. I use it my self and works great, you just have to make a function to create the array and another to convert it into a string when needed. [Help ASAP PLEASE] form_multiselect insert... - El Forum - 02-11-2011 [eluser]chazy (aldever calvo)[/eluser] it's good now,... thanks... i changed the datatype of my table column form integer to varchar... i hope theres another way of storing multiple int values... because i wanted to store the integer values per row in the column. [Help ASAP PLEASE] form_multiselect insert... - El Forum - 02-11-2011 [eluser]defectivereject[/eluser] same here as in other thread, maybe the ", " is the issue? try removing the space after the comma in your model [Help ASAP PLEASE] form_multiselect insert... - El Forum - 02-11-2011 [eluser]Ochetski[/eluser] Well. i guess "ch_act_mat_act_id" is an ID from another table and you want to store a lot of "ch_act_mat_mat_id"'s you can change the collumn to int and insert a row per value. Something like this: Code: $ch_act_mat_mat_id = $this->input->post('ch_act_mat_mat_id'); You will just have to select all with the same act_id instead of exploding a string into ints. =D [Help ASAP PLEASE] form_multiselect insert... - El Forum - 02-11-2011 [eluser]chazy (aldever calvo)[/eluser] nice.. thanks ^_^ i'll try this one... yup... both those ch_act_mat_mat_id and ch_act_mat_act_id are both foreign keys of the table activity_materials in which i will pull the serial of activity_id of activity_table and the material_id of material_table into this table.. [Help ASAP PLEASE] form_multiselect insert... - El Forum - 02-11-2011 [eluser]chazy (aldever calvo)[/eluser] [quote author="Ochetski" date="1297462022"]Well. i guess "ch_act_mat_act_id" is an ID from another table and you want to store a lot of "ch_act_mat_mat_id"'s you can change the collumn to int and insert a row per value. Something like this: Code: $ch_act_mat_mat_id = $this->input->post('ch_act_mat_mat_id'); You will just have to select all with the same act_id instead of exploding a string into ints. =D[/quote] wow! thank you so much! it worked! at last! it's hard to be working alone with my undergrad thesis. thanks for helping me... [Help ASAP PLEASE] form_multiselect insert... - El Forum - 02-13-2011 [eluser]Ochetski[/eluser] Happy to know it worked =D Good luck with your school deadline. [Help ASAP PLEASE] form_multiselect insert... - El Forum - 02-24-2011 [eluser]chazy (aldever calvo)[/eluser] [solved by Ochetski] |