问题描述
|
我在mssql表中有一列,其中包含数字1至101。使用While和if if语句工作正常。我需要添加为101获取灰色图像的功能。这需要修改黄色图像的else if语句,但无法使其正常工作。请检查下例,让我知道我哪里出了问题。谢谢。
作品:
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;
}
出现错误:意外\'> \',期望为\')\'
解决方法
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;
}