sql - How to display multiple values in a MySQL database? -


I was wondering how to display more than one value in the database, for example, you can say The user is the form that asks to type the types of foods such as cookies, candies, apples, roti and so on.

How can I store it in MySQL database under the same field as food?

You may want to read

Do not want to store many values ​​in the field. You want to do something like this:

  form_responses id [whatever other fields are in your form] foods_liveed form_response_id food_name  

Where form_responses is a table containing things that are singular (like a person's name or address, or some such things where there are not multiple values). There is a reference to foods_liked.form_response_id a form_responses table, so the foods which are liked by the person whose reaction number is six, to form_response_id foods_liked in the field.

Edit: Others have suggested a three-table structure, which is definitely better if you are limited to choose your users from the predefined list. In this case, the structure of the three-table may be better that you are giving them the ability to enter their own food items, although if you go on that path then you want to be careful to trigger your input (Trit Whitespace, Fix Capitalization etc.) so that you do not end up with duplicate entries in that table.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -