doubiao9775 2011-06-13 00:19
浏览 16
已采纳

Numerical IfThen值语句失败

I have a column in mssql table that holds numbers 1 thru 101. Using this While and if else if statement works fine. I need to add the ability to get a grey image for 101. This requires the else if statement for the yellow image to be modified but cannot get it to work. Please inspect the lower example amd let me know where I went wrong. Thanks.

WORKS:

while ($row8 = mssql_fetch_array($result8)) {
if ($row8['IPscore'] > 85) {        // Get Green image
  $row8['ScoreIND'] = $Good;
  }
else if ($row8['IPscore'] < 69) {   // Get Red image
  $row8['ScoreIND'] = $Bad;
  }
else {
  $row8['ScoreIND'] = $Fair;        // Get Yellow image
  }

FAILS:

if ($row8['IPscore'] > 85) {       // Get Green image
  $row8['ScoreIND'] = $Good;
  }
else if ($row8['IPscore'] < 69) {  // Get Red image
  $row8['ScoreIND'] = $Bad;
  }
else if  ($row8['IPscore'] (>70 and <84)) {  // Get Yellow image
  $row8['ScoreIND'] = $Fair;
  }
else ($row8['IPscore'] == 101) {    // Get Grey image
  $row8['ScoreIND'] = $LowVol;
  }

GETTING ERROR: unexpected '>', expecting ')'

  • 写回答

1条回答 默认 最新

  • dr200166 2011-06-13 00:22
    关注
    else if  ($row8['IPscore'] (>70 and <84)) { 
    

    change with;

    else if  ( $row8['IPscore'] > 70 and $row8['IPscore'] < 84 ) {  
    

    Edit: Also There is logically error. Check IPscores greater to smaller.

    if($row8['IPscore'] == 101) {    // Get Grey image
      $row['ScoreIND'] = $LowVol;
    }else if ($row8['IPscore'] > 85) {       // Get Green image
      $row8['ScoreIND'] = $Good;
    }else if  ( $row8['IPscore'] > 70 and $row8['IPscore'] < 84  ) {  // Get Yellow image
      $row8['ScoreIND'] = $Fair;
    }else if ($row8['IPscore'] < 69) {  // Get Red image
      $row8['ScoreIND'] = $Bad;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line