Hi all,
I'm trying to insert an array into a table in mysql where one user can have many choices in the same field.
example: name = "joe"; age = "37"; game_titles = "222, 333, 444";
Can somebody help me?
help you with what?
This method is not good. In fact, it's bad. You need to normalize this database design.
Add a new table called 'game_title_details' make it so that it contains the ID of the person and the id of the game_title. Now you can add all the person's choices by adding a new record for each game_title that the person chose.
More about proper database design: http://www.hvt-automation.nl/yapf/index.php?cmd=viewitem&itemid=21
Thanks for your advice. I understand that the example given above does not reflect good design but it's just there for the case. The project I'm working on is far more complex and I do need to insert an array of element into one field of a table.
"and I do need to insert an array of element into one field of a table."
That's the point, do don't have to insert an array.
Foo, he's right, if you enter multiple values into one field, no matter how simple or complex your project is, you will inly be inviting trouble. Normalize the design and putt the info into a separate table...
I understand your point now!~
thanks for the good word Vincent.