Page 1 of 1
multi values in 1 field
Posted: Tue Dec 29, 2009 8:28 pm
by Kitara
HI everyone!
I need help about multi value. Problem is: i have 1 value field but dont know how many value will be inserted to. There value is from some select box by user choose. Maybe 3 or 7 or etc.. but then they must be added to simple value field in mysql. Pls help me if you can. I tried alot way but havent any resolusion!!
Re: multi values in 1 field
Posted: Tue Dec 29, 2009 8:54 pm
by omniuni
Can you back up and try to explain that more clearly?
Re: multi values in 1 field
Posted: Tue Dec 29, 2009 9:01 pm
by Kitara
This is code explain:
First i have input form to choose how many select field. If have input form will be direct to main code with number field - example: 3 will be 3 select boxs.
SO we have 3 select box to choose items. After choosing items, press submit and we must get data from 3 values and run query. My question is how to insert into mysql that form. Data must be in 1 field because we dont know how many select boxs will be used. Thank for help!
Re: multi values in 1 field
Posted: Tue Dec 29, 2009 9:18 pm
by tang
join the value in ",".then you can insert it into only one field.
Re: multi values in 1 field
Posted: Tue Dec 29, 2009 9:23 pm
by josh
Loop over them inserting them until there are no more
Re: multi values in 1 field
Posted: Tue Dec 29, 2009 9:27 pm
by Kitara
i had tried but i always get the last value^_^. Pls post your example code
Re: multi values in 1 field
Posted: Tue Dec 29, 2009 9:33 pm
by tang
first you should post your code, then we can find the problem!
Re: multi values in 1 field
Posted: Tue Dec 29, 2009 9:41 pm
by omniuni
If you have checkboxes, make them in the same group, and name them with [] following them, and PHP will make an array you can loop over nicely.
Code: Select all
<input type="checkbox" name="value[]" value="ONE">
<input type="checkbox" name="value[]" value="TWO">
<input type="checkbox" name="value[]" value="THREE">