Home  >  Article  >  Backend Development  >  Detailed description of php checkbox value_PHP tutorial

Detailed description of php checkbox value_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:35:03870browse

Suppose we have an html page with the following code:

Copy the code The code is as follows:










Pay attention to the name attribute of the input above. The content of each attribute is the same, and they are all test[]. The reason for adding [] is to transfer the content of test into an array. The code content of
checkTest.php is as follows:
Copy code The code is as follows:

echo implode(",",$_POST['test']);
?>

When we output the content, we only need to pay attention to using the implode function to convert the array content into a string. .
Note: This function can be used in situations such as deleting multiple records. For example, Delete from tbl where ID in (implode(",",$_POST['test'])).
Example code:
Copy code The code is as follows:




< ;title>Untitled document


If the html checkbox is to be sent to the php script for processing in the form of a data group, it must be in the form of checkbox[ ]This form









//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
)
Many simple things feel complicated before you do them, but when you do them It's easy, just like this checkbox code.
*/
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322288.htmlTechArticleSuppose we have an html page with the following code: Copy the code and the code is as follows: FORM method="post" action=" checkTest.php" INPUT name="test[]" type="checkbox" value="1" / INPUT type="check...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn