0

I have a form that uses a multi select so you can select multiple options, how would I make it so that if you pick 2 options, it adds them both into the database as

option1,option2,option3

I'm kind of still new to PHP, I know I will have to put it as an array, I'm just not sure exactly how to do it.

2 Answers 2

1

Use varchar field in data base table and then insert it. First take a php variable and assign all values to it should be comma seperated. then use this variable in your query to insert. When you get values by select use explode function there.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, I got the rest from there :)
While being on the stack overflow you should accept answers vote up etc this will increase your and others reputation
1

If you whant to have an array you can use the php explode function:

$your_options = "option1,option2,option3";
$array = explode(",", $your_option);

now you can access with $array[0], $array[1] and so on...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.