dream_high1026 2012-08-29 12:12
浏览 691
已采纳

在单个Switch Case中包含多个变量的“And”

I have the following statement, which has been summarised. I was wondering how to show two variables in a single case.

As shown I want pro_st to = 0 when the criteria for both date_avl and pro_qty have been met, but not sure of the correct way to code it.

case $insert_pro :
    case $pro_exists_row['date_aval'] == '0000-00-00' : and $sql_data['pro_qty'] == 0 :
    case $sql_data['pro_date_avl'] > date('Y-m-d') :
      $sql_data['pro_st'] = '0' ;
      break ;
    default :
      $sql_data['pro_st'] = '1' ;

Any advise would be appreciated.

  • 写回答

2条回答 默认 最新

  • douyou1857 2012-08-29 12:18
    关注

    You look like you need an if or possible an if/elseif statement:

    if (( $pro_exists_row['date_aval'] == '0000-00-00' && $sql_data['pro_qty'] == 0 ) || $sql_data['pro_date_avl'] > date('Y-m-d'))
    {
        // This is the first two conditions of you case statement - either of the conditions are met
        $sql_data['pro_st'] = '0' ;
    }
    else
    {
        // This is he default as neither of the others were met...
        $sql_data['pro_st'] = '1' ;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划