+ 1
Why it caused an error while inserting multiple data into the database by using foreach statements?
5 Respuestas
+ 1
Erin
I had modified your front-end part so the checkboxes triggers the relevant alert messages.
https://code.sololearn.com/WJ6RCjHTM5ae/?ref=app
BUT I still need more information about your table. For example the data types of each of the columns in the "problem" table. Your query was like this;
insert into problem(P_ID, description) values('','$chk')
Did you check the content of <$chk> before you use it in your query? If the 'description' column accepts varchar family then you should wrap <$chk> value with single quotes.
Why are you inserting blank for 'P_ID' column here?
And, considering the 'name' property of your checkboxes are different (grouped by engine, brake etc.). I am not sure what you are trying to do. You also did not name the checkboxes using [] which is how it should be if you want to capture them as array from PHP side. See the following thread in SO 👇
https://stackoverflow.com/questions/4997252/get-post-from-multiple-checkboxes
+ 1
Good job Erin!
Now that the case is solved, you can mark the thread by adding [SOLVED] in the thread title. To have everyone be informed : )
0
Did you know? It cannot be included here in this way as in your attempt. So the code is incomplete. Evaluate is not possible.
I would suggest to try to check first if it works only with one query.
0
Ipang thank you so much for your info. I already correct them all and manage to get the data
0
okay sure then, thank you