Reputation: 119
am having select box with multiple options, like option1,option2,option3,option4,option5
.Now i want to select more than one option.
For Example: Select option1,option5,option3
.and click submit.after submitting the select box need to show the selected items.
in which format to be stored in mysql and what's the exact coding to do that?please help me to get rid of this problem...
Upvotes: 0
Views: 8195
Reputation: 415
Try this:
http://www.aleixcortadellas.com/main/2009/03/20/492/
Upvotes: 1
Reputation: 1244
You could serialize the data in and out.
Use name[] as your name which results in an array in PHP.
$_POST['name'];
serialize($name);
//now insert into DB
Do the opposite to retrieve:
unserialize($name);
But to be honest you are better off looking at more granular methods of storing the data, rather than trying to stuff it all into one field in a database. You could take the array and loop through it storing each choice in a separate row or field.
foreach($name as $value){
//insert $value into db
}
Upvotes: 4