How to write the radio value to the database?

Source: Internet
Author: User
How to write the radio value to several other columns of the database is obtained dynamically and can be successfully written to the database.

This is the question.

NormalAbnormal


It seems that the definition of name is incorrect, but you don't know how to get it. How can I write the selected radio value to the database? Name is not a constant.


The entire form code is attached:

 



[Cldj. php]

 $ V) {mysql_query ("insert into djjl (hao, bh, xm, fangfa, biaozhun, gonghao, name, time, zt) VALUES ('$ hh ', '$ V',' {$ bb [$ I]} ',' {$ cc [$ I]} ',' {$ dd [$ I]} ', '$ _ gh',' $ name', '$ _ time') ") or die (' SQL execution failed! '. Mysql_error () ;}} mysql_close (); _ alert_location (' added successfully! ', 'Ksdj. php');?>


Reply to discussion (solution)

Didn't you write the code?
If there is a problem, you also have a die ('SQL execution failed! '. Mysql_error ());
Can you tell me?

Didn't you write the code?
If there is a problem, you also have a die ('SQL execution failed! '. Mysql_error ());
Can you tell me?



The code "normal" or "abnormal" hasn't been completed yet. I don't know how to write it to the database.

Print_r ($ _ POST) after you submit the file. do you know how to distribute the data?

In addition, all your other controls are written in array format. why is the single-choice button not?

In fact, names like name = "xm []" for multiple rows and columns are not as good as name = "d [$ I] [xm ]"
Even if you press a few more keys, you need to maintain a counter ($ I ).
However, after the submission, each row of data is clustered in one piece, which makes it easy to use.
No need to perform column/column conversion

Print_r ($ _ POST) after you submit the file. do you know how to distribute the data?

In addition, all your other controls are written in array format. why is the single-choice button not?




Name is a variable. I don't know how to fill in the variable in $ _ POST ['']

We recommend that you change the "status" field type to the tinyint type, so that "normal" and "abnormal" options can be handled with 1 and 0, so you don't have to worry about it.
In addition, when saving it, use foreach to record fields and content before executing it.

We recommend that you change the "status" field type to the tinyint type, so that "normal" and "abnormal" options can be handled with 1 and 0, so you don't have to worry about it.
In addition, when saving it, use foreach to record fields and content before executing it.




The name of radio is unknown. Because there are 21 groups of ra with different names

We recommend that you change the "status" field type to the tinyint type, so that "normal" and "abnormal" options can be handled with 1 and 0, so you don't have to worry about it.
In addition, when saving it, use foreach to record fields and content before executing it.



I am the name of radio and I don't know how to upload it. Because there are 21 groups of radio with different names in the loop

Radio selected value = 1 unselected value = 0
When the server retrieves $ _ POST ['Radio '], this should be an array

You define the name in that way, and there is also the restructured array format in the background. We recommend that you define the name value as follows:
Name = "post [$ _ rows ['Bh '] ['Bh']"
Name = "post [$ _ rows ['Bh '] ['xm']"
In this way, each row is an array.
The same is true for the following radio. name = "post [$ _ rows ['Bh '] ['status']"

You define the name in that way, and there is also the restructured array format in the background. We recommend that you define the name value as follows:
Name = "post [$ _ rows ['Bh '] ['Bh']"
Name = "post [$ _ rows ['Bh '] ['xm']"
In this way, each row is an array.
The same is true for the following radio. name = "post [$ _ rows ['Bh '] ['status']"


Modify the number and add. Self-processing
Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.