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;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?