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?
Problems adding float figures together
Moderator: General Moderators
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Problems adding float figures together
Are you sure that your SQL query is actually returning any data?
And what datatype is the fee column?
And what datatype is the fee column?
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: Problems adding float figures together
Please use [syntax=php]tags.
If you var_dump($ai2), what value does it hold?[/syntax]
If you var_dump($ai2), what value does it hold?[/syntax]
Re: Problems adding float figures together
Thanks i have managed to sort it it wasnt holding data but now is