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.