This will be a long 'question' but I have 0 ideas on how to do this so it would also be very hard to formulate that question:
What I'm trying to do: I want to make the admin page from which I can upload a product. For that, I have a file input for the slideshow. That image will be sent to my node.js backend and I'm saving that file in my public/uploads dir. The path file path is then sent back to the frontend and added to an array together with other links for other slides and when I press a submit button, that array gets sent to the backend. I want to save that array in mySQL.
The array that I send to the backend to be uploaded is
[
'uploads/slideshows/nbvnbvdnvvbnSlideshow.jpg',
'uploads/slideshows/nbvnbvdnvvbnSlideshow2.jpg',
'uploads/slideshows/nbvnbvdnvvbnSlideshow3.jpg',
'uploads/slideshows/nbvnbvdnvvbnSlideshow4.jpg',
'uploads/slideshows/nbvnbvdnvvbnSlideshow5.jpg'
]
and is called slidehowPaths.
The length of the array will differ from slideshow to slideshow so I cant use:
db.query(
'INSERT INTO slideshowarrays VALUES (?,?,?,?,?)',
slideshowPaths
)
I tried using something like:
db.query(
`INSERT INTO slideshowarrays VALUES (${'?'+',?'.repeat(slideshowPaths.length - 1)})`,
slideshowPaths
)
But that also throws an error ER_WRONG_VALUE_COUNT_ON_ROW
.
I honestly dont even have a clue of what to do with this.
My Table:
Only
link1
has NN
, and 7 is the maximum number of links I will ever use.
I'm very sorry If I formulated this question terribly, please do ask questions in the comments below if you need clarification. I'd be grateful if there you tell me any solution, no matter how dirty.