PHP checkbox Value

Source: Internet
Author: User

PHP's checkbox value method is a little different from other languages, such

Suppose we have an HTML page,CodeAs follows:

<Form method = "Post" Action = "checktest. php">
<Input name = "test []" type = "checkbox" value = "1"/>
<Input type = "checkbox" name = "test []" value = "2"/>
<Input type = "checkbox" name = "test []" value = "3"/>
<Input type = "checkbox" name = "test []" value = "4"/>
<Input type = "checkbox" name = "test []" value = "5"/>
<Input type = "Submit" name = "Submit" value = "Submit"/>
</Form>

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:

<? PHP
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.

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.