回声检查值1

时间:2018-08-28 20:08:18

标签: php checkbox

这是我的复选框

<?php echo "<input type='checkbox' name='pcu' ".fieldvalue('1').==1 ? 'checked' : '' " value='1' />" ?>

如果fieldvalue1,则应选中该框。

如果fieldvalue的值为1,如何回显“ checked = checked”,而没有检查fieldvalue的值为0

1 个答案:

答案 0 :(得分:2)

它必须为您工作

<?php 
If(fieldvalue==1)
{ 
echo "<input type='checkbox' name='pcu'  checked  value='1' />" ;
}else
{
echo "<input type='checkbox' name='pcu'  value='1' />" ;
}
?>


或在以下情况下使用缩写:

 <input type='checkbox' name='pcu'    <?php 
    (fieldvalue==1 ? echo "checked " : "")  ?> value='1' />