打酱油来了,论坛中,如何在分数变化的时候,显示不同等级的等级图片有一张分数表(score)和  一张图片路径表(level_image)Score表
score_id           score          username
40021              2400             vincent
40022              3600              eric
40023              3000              tomy
...                 ...               ... level_image表
level_image_id      level_image_path                 level
1                   BBS/level_image/列兵.gif         列兵
2                   BBS/level_image/上等兵.gif       上等兵
3                   BBS/level_image/下士.gif         下士
4                   BBS/level_image/中士.gif         中士
5                   BBS/level_image/上士.gif         上士
6                   BBS/level_image/少尉.gif         少尉
7                   BBS/level_image/中尉.gif         中尉
8                   BBS/level_image/上尉.gif         上尉
9                   BBS/level_image/少校.gif         少校
10                  BBS/level_image/中校.gif         中校
11                  BBS/level_image/上校.gif         上校
12                  BBS/level_image/大校.gif         大校
13                  BBS/level_image/少将.gif         少将
14                  BBS/level_image/中将.gif         中将
15                  BBS/level_image/上将.gif         上将怎么样让score为多少的时候就显示什么等级的图片,
例如:
select case when score<=100 then '列兵'
       when score>100 and score<=500 then '上等兵'
       when score>501 and score<=1000 then '下士'
       when score>1001 and score<=1500 then '中士'
       when score>1501 and score<=2000 then '上士'
       when score>2001 and score<=2500 then '少尉'
       when score>2501 and score<=3000 then '中尉'
       when score>3001 and score<=3500 then '上尉'
       when score>3501 and score<=4000 then '少校'
       when score>4001 and score<=4500 then '中校'
       when score>4501 and score<=5000 then '上校'
       when score>5001 and score<=5500 then '大校'
       when score>5501 and score<=6000 then '少将'
       when score>6001 and score<=6500 then '中将'
       when score>6501 and score<=7000 then '上将'
else '其他' end
from score

其中分数表中的分数是随发帖的增多而增加的,就是说是动态变化着的,
所显示的图片也是随分数的增加而显示出来的
问:要在分数慢慢的增加的时候显示出来的(leve)等级图片所对应的图片地址(level_image_path)

解决方案 »

  1.   

    我不知道怎么在查询出分数为2600分显示的图片为BBS/level_image/中尉.gif图片
      

  2.   

    写个方法在绑定的时候 传一个 score 进来 返回一个 string  内容就是对应的 level_image_path                方法内容 用if 判断 score  是属于哪个区间的 然后赋给相应的值 即可
      

  3.   

    这个方法就可以
    或者
    select case when score <=100 then '列兵'....... 
    改为:select case when score <=100 then 'image/列兵.jpg' 
    直接转成img的url。