I have a form where I needed to split into two table in the database. tbl_1
consist of single value per column, then tbl_2
consist of multiple value per column. I know if I pass multiple data per column I'm going to violate a normalization in database. So what I did I reference tbl_1
to tbl_2
. The problem is I don't know how to save each value in an array to a column. example Classification has 4 value which I needed to save in tbl_2
and reference it to tbl_1
. How am I able to do this? I'm using PDO
.
HTML snippet:
<input type="text" name="classification[]" placeholder="Classification No. 1" />
<input type="text" name="classification[]" placeholder="Classification No. 2" />
<input type="text" name="classification[]" placeholder="Classification No. 3" />
<input type="text" name="classification[]" placeholder="Classification No. 4" />
So for each value will create 4 rows that has the same id being reference to tbl_1
. It should be like this: