How the value of radio is written to the database

Source: Internet
Author: User
The other columns are dynamically fetched and can be successfully written to the database.

now, here's the thing.

NormalNot normal


It feels like the name is wrong, but I don't know how to get it. How can I write the radio selected values to the database? The name is not good with constants.


Attach the entire form code:




"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 (' Add success! ', ' ksdj.php ');? >


Reply to discussion (solution)

You didn't write the code, did you?
There is a problem, you also have die (' SQL execution failed! '. Mysql_error ());
Can't I tell you something?

You didn't write the code, did you?
There is a problem, you also have die (' SQL execution failed! '. Mysql_error ());
Can't I tell you something?



I am now "normal" or "abnormal" This code is not finished, do not know how to write to the database

After you submit Print_r ($_post); And look at how the data is distributed, don't you know what to do?

In addition, your other controls are written in array format, why radio button not?

In fact, multi-row multi-column name= "xm[" such a name than Name= "d[$i][XM]" Such a name
Although you press several keys, you also maintain a counter ($i).
But after submission, each line of data is gathered in one piece, it is convenient to use
No need to do it anymore.

After you submit Print_r ($_post); And look at how the data is distributed, don't you know what to do?

In addition, your other controls are written in array format, why radio button not?




Name is a variable, I do not know how to fill in $_post["

Proposed landlord to the "status" field type of tinyint type bar, so that with 1 and 0 can handle "normal" and abnormal options, not so troublesome
When you save it, of course, use foreach to record fields and content before you do it.

Proposed landlord to the "status" field type of tinyint type bar, so that with 1 and 0 can handle "normal" and abnormal options, not so troublesome
When you save it, of course, use foreach to record fields and content before you do it.




The name of radio does not know how to preach. Because the loop is down, there are 21 different RA sets of name

Proposed landlord to the "status" field type of tinyint type bar, so that with 1 and 0 can handle "normal" and abnormal options, not so troublesome
When you save it, of course, use foreach to record fields and content before you do it.



I'm the name of radio, I don't know how to preach. Because of the loop, there are 21 different name radio

Radio is selected value = 1 unchecked value = 0
$_post[' Radio ' when the server is fetched, this should be a number of groups

You define name like that, and you have a reorganization array format in the background. It is recommended that you define the name value as follows:
Name= "post[$_rows[' bh ']][' bh ']"
Name= "post[$_rows[' bh ']][' XM ']"
So each row is an array.
The back of the radio is the same, name= "post[$_rows[' bh ']][' status ']"

You define name like that, and you have a reorganization array format in the background. It is recommended that you define the name value as follows:
Name= "post[$_rows[' bh ']][' bh ']"
Name= "post[$_rows[' bh ']][' XM ']"
So each row is an array.
The back of the radio is the same, name= "post[$_rows[' bh ']][' status ']"


Modified with a "]" number above. Self-processing
  • 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.