+ 1

Why it caused an error while inserting multiple data into the database by using foreach statements?

https://code.sololearn.com/W0400zO7jtE0/?ref=app

17th Jun 2020, 6:23 PM
Erin
5 Respostas
+ 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
18th Jun 2020, 8:57 AM
Ipang
+ 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 : )
18th Jun 2020, 2:16 PM
Ipang
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.
17th Jun 2020, 9:15 PM
JaScript
JaScript - avatar
0
Ipang thank you so much for your info. I already correct them all and manage to get the data
18th Jun 2020, 2:06 PM
Erin
0
okay sure then, thank you
18th Jun 2020, 4:02 PM
Erin