doumie6223
doumie6223
2015-02-12 06:11
浏览 29
已采纳

如果像这样的会话中的条件,访问页面的正确语法是什么?

excuse me I have little problem what is right syntax to access page if I have condition like this (status) in session if status=0 and 2 can be access pegawai

this if status=0,

<?php if($this->session->userdata('STATUS')==0) {?> <li><a href="<?php echo base_url() ?>pegawai"><i class="icon-user"></i>Pegawai</a></li><?php } ?>

so I want this page can be access if status 0 and 2 what syntax that should be used?

I have make this

<?php 
if($this->session->userdata('STATUS')==0) {
?> 
    <li><a href="<?php echo base_url() ?>pegawai"><i class="icon-user"></i>Pegawai</a></li>
<?php 
} 
?>
<?php 
if($this->session->userdata('STATUS')==2) {
?> 
    <li><a href="<?php echo base_url() ?>pegawai"><i class="icon-user"></i>Pegawai</a></li>
<?php 
} 
?>

so if status 0 and 2 can be acces but it's not efficient

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • drwpbrv668670
    drwpbrv668670 2015-02-12 06:16
    已采纳

    Are you asking how to use an Or logical operator?

    <?php if($this->session->userdata('STATUS')==0 || $this->session->userdata('STATUS')==2): ?> 
        <li><a href="<?php echo base_url() ?>pegawai"><i class="icon-user"></i>Pegawai</a></li>
    <?php endif; ?>
    

    Answering but also down-voting this and suggesting you close it. Shows a lack of searching for the answer. You might want to read an intro to coding PHP.

    点赞 评论
  • drno94939847
    drno94939847 2015-02-12 06:17

    Make it simpler like this

    <?php
    if( $this->session->userdata('STATUS')==0 || $this->session->userdata('STATUS')==2) {
    ?>
        <li><a href="<?php echo base_url() ?>pegawai"><i class="icon-user"></i>Pegawai</a></li>
    <?php
    }
    ?>
    
    点赞 评论

相关推荐