2011-06-13 81 views
1

我在mssql表中有一列保存数字1到101.使用此While和if if else语句正常工作。我需要添加为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; 
    } 

抵达ERROR:意想不到 '>',希望 ')'

回答

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

谢谢摩西!我不得不在红色和绿色的图像上使用该方法,而只使用灰色。它工作正常。 – 2011-06-13 00:51:35