开发者

display image with valors <= 300

hy, sorry for my bad language, i need a ideea, i want to create a rank player script and for the moment i write this:

$grade = "Select OnlineHours from MEMB_STAT where memb___id='$account_id'";
$grade_show = mssql_fetch_row($grade);
if ($grade_show['0'] <= 100) { $grade_show[0] = "<i mg src='template/ezra/images/rank/recruit.png'>"; }
if ($grade_show['0'] <= 300) { $grade_show[0] = "<i mg sr='template/ezra/images/rank/apprentice.png'>"; }
if ($grade_show['0'] <= 700) { $grade_show[0] = "<i开发者_StackOverflow mg sr ='template/ezra/images/rank/private.png'>"; }
if ($grade_show['0'] <= 1000) { $grade_show[0] = "<i mg sr='template/ezra/images/rank/corporal.png'>"; }
if ($grade_show['0'] <= 1300) { $grade_show[0] = "<i mg sr='template/ezra/images/rank/sergeant.png'>"; }
if ($grade_show['0'] <= 1500) { $grade_show[0] = "<i mg sr='template/ezra/images/rank/gunnerysergeant.png'>"; }
if ($grade_show['0'] <= 1900) { $grade_show[0] = "<i mg sr='template/ezra/images/rank/Lieutenant.png'>"; }
if ($grade_show['0'] <= 2100) { $grade_show[0] = "<i mg sr='template/ezra/images/rank/captain.png'>"; }
if ($grade_show['0'] <= 2500) { $grade_show[0] = "<i mg sr='template/ezra/images/rank/major.png'>"; }
if ($grade_show['0'] <= 2800) { $grade_show[0] = "<i mg sr='template/ezra/images/rank/commander.png'>"; }
if ($grade_show['0'] <= 3000) { $grade_show[0] = "<i mg sr='template/ezra/images/rank/colonel.png'>"; }
if ($grade_show['0'] <= 4000) { $grade_show[0] = "<i mg sr='template/ezra/images/rank/brigadier.png'>"; }
if ($grade_show['0'] <= 5000) { $grade_show[0] = "<i mg sr='template/ezra/images/rank/general.png'>"; }

but if value is 0 or 100 or 4000 or 500 script display the last if, how to create for display each one; if OnlineHours is <= 100 show but if OnlineHours is <= 300 but no sub 100 display Please Help with this.


I believe what you are looking for is else if. Something along these lines:

...
    else if ($grade_show['0'] >= 300) { $grade_show[0] = "<i mg sr='template/ezra/images/rank/apprentice.png'>"; } 
    else if ($grade_show['0'] >= 100) { $grade_show[0] = "<i mg src='template/ezra/images/rank/recruit.png'>"; }

Its important to start with the highest first and work down.

Basically, if >= 5000, show an image, else if >= 4000 show a different image.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜