I am trying to insert values from a multi select drop down in a form to a mysql db column. For example: The drop down would have one or more choices chosen then when the form is posted it would insert the data into one column in a mysql db. I'm stuck at how to insert the data.
Php – Inserting an array into a thesql database column
arraysdatabaseMySQLPHP
Related Topic
- Javascript – How to check if an array includes a value in JavaScript
- Php – Deleting an element from an array in PHP
- Javascript – How to insert an item into an array at a specific index (JavaScript)
- Javascript – Loop through an array in JavaScript
- Sql – What are the options for storing hierarchical data in a relational database
- Javascript – How to remove a specific item from an array
- Javascript – For-each over an array in JavaScript
Best Answer
If you want to insert in single row then you can use implode() to generate comma separated data, or you can do json_encode() and add to your colum.
Say you get the data as
Thats for inserting data in single column. While retrieving you can do explode() or json_decode() to get the return data and can use them in the multi-select again.
If you want one row for each item then just loop through the array and add them