How to change an image according to values?

I am getting ready with a quiz using php, in this when i submit answers if it is
[hr]" >=5 " ------- an image (poor)
" 6 to 10 " ------- an image (ok)
" 11 to 14" ------- an image (good)
" 15=< " ------- an image (excellent)[hr]

My point is bringing out specific badge images for the performance according to the users quiz result. How to do this? Please help :frowning: :frowning: :frowning:

Here’s a two for one:

[php]

<?php $intScore = 12; if ($intScore <= 5) { $strImage = 'Poor'; } elseif (($intScore >= 6)&&($intScore <= 10)) { $strImage = 'OK'; } elseif (($intScore >= 11)&&($intScore <= 14)) { $strImage = 'Good'; } else { $strImage = 'Excellent'; } echo $strImage; $intScore = 6; switch ($intScore){ case ($intScore <= 5): $strImage = 'Poor'; break; case (($intScore >= 6)&&($intScore <= 10)): $strImage = 'OK'; break; case (($intScore >= 11)&&($intScore <= 14)): $strImage = 'Good'; break; default : $strImage = 'Excellent'; } echo $strImage; ?>

[/php]

On a side note, watch your greater and less than signs, it looks like you have them the wrong way round.

=5 is greater than or equal to 5.

@xerxes:

This works! a much needed help! :wink: thank you so much…

Sponsor our Newsletter | Privacy Policy | Terms of Service