Numerical IfThen值语句失败

时间:2011-06-13 00:19:28

标签: php sql

我在mssql表中有一个列,其中包含数字1到101.使用此while和if else if语句正常工作。我需要添加获取101的灰色图像的功能。这需要修改黄色图像的else if语句,但无法使其工作。请检查下面的示例,并告诉我出错的地方。感谢。

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
  }

失败:

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;
  }

获得错误:意外'&gt;',期待')'

1 个答案:

答案 0 :(得分:5)

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

改变;

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

修改 还有逻辑上的错误。检查更大到更小的IPscores。

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;
}