2011-06-13 11 views
1

1から101の番号を保持するmssqlテーブルの列があります。このwhileとif else ifステートメントを使用すると問題なく動作します。 101の灰色画像を取得する機能を追加する必要があります。これは、変更する黄色のイメージに対してelse ifステートメントが必要ですが、動作させることはできません。下の例のamdを調べて、どこが間違っているかを教えてください。ありがとう。Numerical IfThen valueステートメントが失敗しました

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

取得中にエラー:予期しない '>'、期待 ')'

答えて

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

変更。

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

編集: はまた、論理的に誤りがあります。 IPスコアーを小さくして確認してください。

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

ありがとうございました!赤と緑の画像でその方法を使用しなければなりませんでした。それは正常に動作しています。 –

関連する問題