otuatail Posted January 21, 2010 Share Posted January 21, 2010 Hi I have adb field `Cost` decimal(4,2) NOT NULL default '0.00' I want to iterate through the table put data into a <table> What i have is this but it dosn't work. $totals = (float)"0.00"; while ($row = mysql_fetch_array($rs)) { $totals .= (float)$row["Cost"]; } echo (float)$totals; Can't figure this addition. Thanks Quote Link to comment Share on other sites More sharing options...
Mchl Posted January 21, 2010 Share Posted January 21, 2010 .= is for concatenating strings. To add numbers use += Quote Link to comment Share on other sites More sharing options...
otuatail Posted January 21, 2010 Author Share Posted January 21, 2010 Ok thanks. the only problem I have is i get 6163 nit 6163 .00 if this is a float, I need .00 Desmond. Quote Link to comment Share on other sites More sharing options...
Mchl Posted January 21, 2010 Share Posted January 21, 2010 number_format or money_format Quote Link to comment Share on other sites More sharing options...
otuatail Posted January 22, 2010 Author Share Posted January 22, 2010 Thanks for your help problem solved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.