如何回显0,何时不勾选复选框?

时间:2015-01-12 11:09:56

标签: php

如何回显0,何时不勾选复选框?

当按下提交按钮时,它将回显11 但是我想要回显101(echo 0表示未检查ckeckbox)。

我该怎么做?

<form id="form02" name="form02" method="post">
    <input name="h_type[]" type="checkbox" id="h_type[]" value="0" checked/><input  type="hidden" name="more[]" value="1"> <br/>
    <input name="h_type[]" type="checkbox" id="h_type[]" value="1" /><input  type="hidden" name="more[]" value="1"> <br/>
    <input name="h_type[]" type="checkbox" id="h_type[]" value="2" checked/><input  type="hidden" name="more[]" value="1"> <br/>    
    <input type="submit" name="button" id="button" value="Submit" />
</form>


<?php
$data_h_type=$_POST['h_type'];
$data_more=$_POST['more'];

if(count($data_h_type)>0){
    foreach($data_h_type as $key=>$value){
          echo $data_more[$value];
                  echo "<br>";
    }   
}

?>

1 个答案:

答案 0 :(得分:0)

 echo isset($data_more[$value]) ? $data_more[$value] : 0;