multi values in 1 field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Kitara
Forum Newbie
Posts: 5
Joined: Fri Nov 20, 2009 12:34 am

multi values in 1 field

Post 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!!
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: multi values in 1 field

Post by omniuni »

Can you back up and try to explain that more clearly?
Kitara
Forum Newbie
Posts: 5
Joined: Fri Nov 20, 2009 12:34 am

Re: multi values in 1 field

Post 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!
tang
Forum Newbie
Posts: 6
Joined: Sun Nov 15, 2009 9:14 pm

Re: multi values in 1 field

Post by tang »

join the value in ",".then you can insert it into only one field.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: multi values in 1 field

Post by josh »

Loop over them inserting them until there are no more
Kitara
Forum Newbie
Posts: 5
Joined: Fri Nov 20, 2009 12:34 am

Re: multi values in 1 field

Post by Kitara »

i had tried but i always get the last value^_^. Pls post your example code
tang
Forum Newbie
Posts: 6
Joined: Sun Nov 15, 2009 9:14 pm

Re: multi values in 1 field

Post by tang »

first you should post your code, then we can find the problem!
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: multi values in 1 field

Post 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">
Post Reply