当我的数据为<div>
时,我正在尝试隐藏zero
代码...
我有if condition
if ($_SESIION['m1']==0)
{
我希望取消激活代码,这是我的<div>
代码
<div class="right"><a href="<?php echo $checkout; ?>" class="button" id="checkout"><?php echo $button_checkout; ?></a></div>
else
应激活<div>
..
我真的不知道如何实现这一目标。
答案 0 :(得分:2)
如果您想完全删除div,请执行此操作;
if( !empty( $_SESSION[ 'm1' ] ) )
{
//echo your div here, it will only appear when m1 is not 0/false/blank/null
}
else
{
//m1 is 0/false/blank/null, you can print out a relevant message here
}
如果要在HTML中包含div,但要隐藏它,只需添加必要的样式;
<div class="right" <?php if( empty( $_SESSION[ 'm1' ] ) ) { ?>style="display:none;"<?php } ?>>
<a href="<?php echo $checkout; ?>" class="button" id="checkout"><?php echo $button_checkout; ?></a>
</div>
答案 1 :(得分:0)
<?php
$hide="";
if ($_SESIION['m1']==0)
{
$hide="style='display:none;'";
}
?>
<div class="right" <?php echo $hide;?>><a href="<?php echo $checkout; ?>" class="button" id="checkout"><?php echo $button_checkout; ?></a></div>