Hi guys,
I have a multiple select box I’ve succeeded to insert into my database, but when I insert the data, rows are obviously created for each value inserted. I looked up serialization to try and rearrange the array in a string so only one row is created, but can’t get it.
What am I doing wrong.
well, for starters, thinking that you should put multiple values in a string so only one row is created
better to create multiple rows, that way searching on any given value will be an efficient, indexed query rather than forcing a scan of your entire table
How do I put multiple values in a string when using a select box with multiple values?
I know how to use the foreach function, creating an array but I’m having a hard time converting it into a string. I don’t need multiple rows in my database, not for this field at least.
Thanks Centered effect, it worked. I hate bothering you again but if or when you have time could you please explain to me what these three lines of your code mean. Because I just copy-pasted it without learning anything.
They did the job, but what does $array = array(); mean or $key => $value???
And how would I echo it out as a normal string. Just plain text that will show beer, tea (assuming I chose those two)?
Sorry, here is an easier code using implode and explode:
Implode would collapse the array into a string delimited by what you choose. explode will do the opposite