Skip to content
Advertisement

how to insert array of data per column in MySQL?

I have arrays stacked in 1 array and I would like to insert each array per column in MySQL. I have reached to insert all data in arrays to 1 column, but I want to insert an array per column. Please see the screenshot and code below.

Image of array stack

JavaScript

Advertisement

Answer

I just found a solution for this case. It can be a little bit confusing but it is working. Maybe there exists way easier and understandable solution, but this is the solution I have at the moment.

In the code above I was using only 1 array iterator, which was returning me an array. I decided to iterate the returned array to get each integer and insert data into MySQL, also the (test${i+1}) sets array into necessary column.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement