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.

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

报告相同问题?