Jump to content

add float figures


gotornot

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/174685-add-float-figures/
Share on other sites

The posted code is dependent on the while() loop executing. Have you checked that the query worked and returned a result resource (use an if(){} statement around the query) and have you checked if there were any rows in that result resource (use mysql_num_rows() )?

Link to comment
https://forums.phpfreaks.com/topic/174685-add-float-figures/#findComment-920677
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.