I have been getting information from the database which adds the cost of each item in a table.
Every is working 100% apart from when the cost is equal to a curtain sum it does not become equal, it is always greater.
For example if 30.02 == 30.02 it should become true, but its saying it is greater than.
Basically I have a foreach loop which is getting the cost of each invoice from an array which goes like this:
$i_array = array('2','3','4','5');
$i_total = 0;
$a_total = 0;
foreach($i_array as $i){ $i_total += floatval($i); }
Then I have a little bit of code which checks all invoices and if there are any it then adds them like this:
$query = $pdo->prepare("SELECT cost FROM tablename WHERE id=id");
$query->execute(array(':id' => $_GET['id']));
while($fetch = $query->fetch()){
$a_total += floatval($fetch['cost']);
}
From there I do a simple if statement:
if($i_total > $a_total){ echo 'Too Much'; }
Now the problem is if i_total is lets say 30.02 and lets say the a_total is also 30.02 then it should be equal and it should not echo Too Much but its still echos Too Much.
If the i_total is lower or greater it is fine, just when its equal.
Anyone could shed some light on this it would be greatful :)