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

[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.

Use brackets [ ] and try

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.