Page 1 of 1

Problems adding float figures together

Posted: Fri Sep 18, 2009 5:33 am
by gotornot
Hi I am trying to add float figures together but for some reason its not working with the script below any ideas?

$ai = 0;
// Round upp all fees add them together
while ($feeitem = mysql_fetch_array($cartr))
{
$ai2 = $feeitem["fee"];
$ai = $ai + $ai2;
}
echo $ai;

All it does is output the 0

Figures are like 4.65 and 66.50

Any ideas?

Re: Problems adding float figures together

Posted: Fri Sep 18, 2009 6:13 am
by Mark Baker
Are you sure that your SQL query is actually returning any data?
And what datatype is the fee column?

Re: Problems adding float figures together

Posted: Fri Sep 18, 2009 6:43 am
by Ollie Saunders
Please use [syntax=php]tags.

If you var_dump($ai2), what value does it hold?[/syntax]

Re: Problems adding float figures together

Posted: Fri Sep 18, 2009 7:37 am
by gotornot
Thanks i have managed to sort it it wasnt holding data but now is