Phpcheckbox value description _ PHP Tutorial

Source: Internet
Author: User
The value of phpcheckbox is described in detail. Let's set up an html page. the code is as follows: Copy the code as follows: formediahodpostactionchecktest. phpINPUTnametest [] typecheckboxvalue1INPUTtypecheck sets up an html page. the code is as follows:

The code is as follows:




Note that the name attribute of input is the same for each attribute and is test []. the reason for adding [] is that the content of test is transmitted as an array.
The code of checkTest. php is as follows:

The code is as follows:


Echo implode (",", $ _ POST ['test']);
?>


When outputting content, you only need to use the implode function to convert the array content to a string.
Note: This function can be used to delete multiple records. For example, Delete from tbl where ID in (implode (",", $ _ POST ['test.
Instance code:

The code is as follows:





Untitled Document


The html check box must be in the format of checkbox [] if you want to send a data group to the php script for processing.



// Determine whether to click submit
If ($ _ POST)
{
$ Array = $ _ POST ['checkbox'];
Print_r ($ array );
}
/*
Result:
Array
(
[0] => 1
[1] => 2
[2] => www.jb51.net
[3] => jb51.net
)
A lot of simple things are complicated before they are done, but they are easy to do, just like this check box code.
*/
?>

The signature code is as follows: FORM method = "post" action = "checkTest. php "INPUT name =" test [] "type =" checkbox "value =" 1 "/INPUT type =" check...

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.