[英]How can i show value when checkbox was checked using loop for?
How can i show value when checkbox was checked using loop for ? 当使用loop选中复选框时,如何显示值?
..................................................................................................................................................................... ................................................... ................................................... ................................................... ......
<form method="post">
<input type="checkbox" name="a_0" value="0">0
<input type="checkbox" name="a_1" value="1">1
<input type="checkbox" name="a_2" value="2">2
<input type="checkbox" name="a_3" value="3">3
<input type="checkbox" name="a_4" value="4">4
<input type="submit" name="submit">
</form>
<?php
if(isset($_POST["submit"]))
{
for($i=0;$i<4;$i++)
{
if(${"_POST[a_{$i}]"} != '')
{ echo ${"_POST[a_{$i}]"}; }
else
{ echo "no"; }
}
}
?>
Try like this: 尝试这样:
<?php
if(isset($_POST["submit"]))
{
for($i=0;$i<4;$i++)
{
if(${"_POST[a_{$i}]"} != '')
{ echo $_POST['a_{$i}']; }
else
{ echo "no"; }
}
}
?>
Change: 更改:
${"_POST[a_{$i}]"}
To: 至:
$_POST['a_' . $i]
Or (note the double quotes): 或(请注意双引号):
$_POST["a_$i"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.