Home > Backend Development > PHP Tutorial > How to get the selected value of checkbox in php (example)_PHP tutorial

How to get the selected value of checkbox in php (example)_PHP tutorial

WBOY
Release: 2016-07-13 10:34:36
Original
1986 people have browsed it

Reprinted from: http://blog.csdn.net/vip_linux/article/details/22975713

In PHP development, how to get the selected value of the checkbox control in the previous page? and output it.

Here is an example of getting the value of a checkbox in PHP. Let’s study the method of getting the value of a checkbox in PHP.

  1.  $music = $_POST['music'];
  2.  
  3. //Get the number of selected checkboxes
  4.  
  5. $coun=count($music);
  6.  
  7. if ( is_array( $music) ) {
  8.  
  9. echo ‘You have selected: ';
  10.  
  11. foreach ( $music as $key => $var )
  12.  
  13. echo ' ['.$var. ']';
  14.  
  15. echo $key;
  16.  
  17. } // Scripting School Editing
  18.  
  19. ?>
  20.  
  21.  
  22. pop music
  23.  
  24. Country Music
  25.  
  26. Classical Music
  27.  
  28.  

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/749823.htmlTechArticleReprinted from: http://blog.csdn.net/vip_linux/article/details/22975713 In PHP development, How to get the selected value of the checkbox control on the previous page? and output it. Share one here...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template