S
S
Sergey Defactov2018-05-22 22:05:40
MySQL
Sergey Defactov, 2018-05-22 22:05:40

How to store multiple values ​​in 1 column?

There is a category selection when adding material, it was necessary to make a multi -selection
in the form of writing

<select multiple="multiple" name="post_category[]" class="form-control" id="post_category">

through Debug it is clear that when submitting the form, the data is sent
category[2]
category[3]
But only 1 category is stored in the database category
table structure5b046a02088b9899546263.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Popov, 2018-05-22
@be_a_dancer

You don't know what data normalization is. The design of relational databases requires that the data be as primitive as possible.
I recommend rethinking the structure of the database and reading this material.

I
ivankomolin, 2018-05-23
@ivankomolin

1. You need to look at the data saving code.
Apparently, it is simply not provided for saving 2 or more categories
2. It is necessary to think about the data storage structure and data output.
Simply changing the html will not be able to assign material to multiple categories.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question