是否可以在IF条件中添加参数?

时间:2018-03-09 10:01:24

标签: php if-statement

我想显示表中的数据。某些用户可能只有某些数据。我有这个参数:

if($person == "nonmember"){
    $st_show = ' == 3'; //For non member show rows with status of 3
}else{
    $st_show = ' <> 3'; //For member show rows with status of not 3. Status may dynamically increased and changed
}

如何根据上面的参数循环行。像这样:

if($rows->STATUS echo $st_show){
    //show data based on $person
}

我知道它会返回错误。除了数据库中的这些限制之外,我有什么解决方案吗?

1 个答案:

答案 0 :(得分:3)

像...一样的东西。

if(($person == "nonmember" && $status == 3) || 
          ($person == "member" && $status <> 3)){
   // Show record
}
相关问题