Hello With PHP and MySQL, i would like to store multiple values in a single field in a table. What's the best way to achieve this? say while submitting a form, i have a multiple checkboxes where i can select the values, and i want those values to be store into a single field. thank you
seperate them with spaces or something, like so: $pieces = "value1 value2 value3"; when it comes time to get them, put them all in a string and use the explode function: $pieces = explode(" ", $pieces ); This will create an array, so it will now look like: $pieces[0] = "value1"; $pieces[1] = "value2"; $pieces[2] = "value3";
If you think that you'll ever be querying against this field later on, though, don't shove multiple values into it. Make a mapping table or something.