[Help ASAP PLEASE] form_multiselect insert... |
[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
[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..
[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.
[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.
[eluser]defectivereject[/eluser]
same here as in other thread, maybe the ", " is the issue? try removing the space after the comma in your model
[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
[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..
[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...
[eluser]Ochetski[/eluser]
Happy to know it worked =D Good luck with your school deadline.
|
Welcome Guest, Not a member yet? Register Sign In |