dqyq88053 2015-07-04 11:11
浏览 105
已采纳

如何使用PHP隐藏/显示文本内容?

I am confused and not sure why this code is not working.

Here is the original code :

    //start date to end date
    <?php if($show5 < $show6) { ?>

     <a>show content</a>

     <?php }?>

If 'start date' and 'end date' values are empty then I want to remove or hide <?php if($show5 < $show6) { ?> <?php }?> and 'show content'.

And if 'start date' and 'end date' values are not empty then I want to remove or hide <?php if($show5 != '' && $show6 != '') { ?> <?php }?> and show content. If start to end date are not expired and if start to end date are expired then hide the content.

<?php if($show5 != '' && $show6 != '') { ?> 

    //start date to end date
    <?php if($show5 < $show6) { ?>

    <?php } ?>

    <a>show content</a>

    <?php if($show5 != '' && $show6 != '') { ?> 

    <?php } ?>

<?php }?>
  • 写回答

2条回答 默认 最新

  • douyinbo3361 2015-07-04 11:22
    关注

    is this what you were trying to do?

    <?php if ($show5 != '' && $show6 != '') { ?> 
        //start date to end date
        <?php if (strtotime($show5) < strtotime($show6)) { ?>
            <a>show5 content</a> 
        <?php } ?>
        <?php if (strtotime($show5) > strtotime($show6)) { ?>
            <a>show6 content</a> 
        <?php } ?>
    <?php } ?>
    

    The bottom code was not necessary and therefore it was throwing an error. Also the html had to be moved few lines top and you were missing one <?php } ?>

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来