How to insert check box data into the database in the form
Source: Internet
Author: User
How do I insert the check box data in the form into the database? I made a check box in the form. The data in the selected check box is saved in an array, traversed the array, and each element is put together and saved in a string. For example, [select] basketball [] Badminton [] table tennis [select] selected Shot put: the basketball shot put is saved in the $ pre_u_have variable echo $ pre_u_have; // it can be displayed: in basketball shot put, how do I insert the check box data in the table form into the database?
I made a check box in the form. The data in the selected check box is saved in an array, traversed the array, and each element is put together and saved in a string. For example:
[Choice] Basketball
[] Badminton
[] Table tennis
【Option】 shot put
The selected: basketball shot put is saved in the $ pre_u_have variable.
Echo $ pre_u_have; // displayed: basketball shot put
I want to insert the form into the database. check box data is inserted into the u_have field.
The u_have field cannot match Form. u_have [] because it is a check box.
So I inserted a hidden domain
--------------- 1 ------------------------------
In this example, $ pre_u_have is directly assigned to u_have. the insert operation is successful, but the field in the database displays $ pre_u_have (the variable name is treated as a string)
---------------------- 2 ----------------------------
This shows that coloum "u_have" does not allow NULL, which means data insertion into the database fails.
-----------------------------------------------------
Where is my current problem? I stayed up all night and the problem still could not be solved.
What we see on the Internet is:
$ _ POST ['pre _ u_have '];
This statement
------ Solution --------------------
Maybe this is not a problem.
------ Solution --------------------
PUT the PHP code IN line 1st, followed by the for loop, NO PUT IN HTML
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.