dongyuying1507 2014-04-24 04:41
浏览 11
已采纳

PHP显示按钮,如果某些值是如此,那么

I am currently programming a PHP application, and I am wondering if it is possible for a link to only show if a certain database variable is so and so.

For example, have PHP check if the value for the user currently logged in is "Admin" under the "Rank" variable in the table, and if it is, display the link. If not, don't show anything.

Many thanks, and if anyone is confused, I'm willing to give more details.

  • 写回答

1条回答 默认 最新

  • du1068 2014-04-24 04:50
    关注

    Good thing about PHP is that you can merge HTML & PHP code both and here is your answer:

        <?php if('databaseField' === 'value to compare'){ ?>
             HTML LINK TAG
        <?php } ?>
    

    use === instead of == because you want to match your session value with database value and in case of login too. so for security purpose use ===. it will check type of both variable as well as value.

    Feel free to ask for any doubt here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)