0

I have an If Statement that isnt loading the right image any help would be great

<?php
   if($formattedNum6 > $PeriodSalesTarget):{
      echo '<img src="images/TargetMetGreen.png" alt="" />';}
      elseif($formattedNum6 > $CummulativePeriodSalesTarget):{
         echo '<img src="images/TargetMet.png" alt="" />';}
         else:{
            echo '<img src="images/TargetNotMet.png" alt="" />';}
            endif;
?>

$formattedNum6 = 515,839
$PeriodSalesTarget = 1,366,000
$CummulativePeriodSalesTarget = 503,600

So it should show TargetMet.png but instead is showing TargetMetGreen.png

If i change the PeriodSalesTarget to 999,999 it works so looks like it isnt treating the values as numbers but i dont know how to fix

Edited by Reverend Jim: Moved to programming forum

3
Contributors
2
Replies
19
Views
1 Week
Discussion Span
Last Post by Anil_17
0

[Editor's note: As of PHP 5.4.4 this is no longer true. Integral strings that overflow into floating point numbers will no longer be considered equal.]

From http://php.net/manual/en/types.comparisons.php

But the number is not large enough for that to happen. I don't know which version PHP so for now, test this by calling these ints by adding (int) to the values in line 2.
Read how at http://php.net/manual/en/language.types.integer.php

Lastly, be sure your png graphics are what you think they are. Check those again.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.