new_php85 Posted September 9, 2008 Share Posted September 9, 2008 iii.... see again i make some calculation...when i sum all (salary) the value is correct but it appear like this eg:223632.2321451255 (see code a). i just want the 'total_ee' like 223632.23 which is 2 decimal point. a) $q2 = "SELECT SUM(ammount_ee) AS total_ee FROM ee WHERE staff_id='$staff_id'"; $result2 = mysql_query($q2) or die('Query failed. ' . mysql_error()); $row2 = mysql_fetch_array($result2); echo $row2['total_ee'] below some code that i have wrote. but after i add $num2 = number_format($row2, 2), the amount = 1 (see code b) b) $q2 = "SELECT SUM(ammount_ee) AS total_ee FROM ee WHERE staff_id='$staff_id'"; $result2 = mysql_query($q2) or die('Query failed. ' . mysql_error()); $row2 = mysql_fetch_array($result2); $num2 = number_format($row2, 2); echo $num['total_ee'] how to make total_ee become 2 decimal point??? ??? ??? ??? Link to comment https://forums.phpfreaks.com/topic/123400-solved-how-to-get-value-for-2-decimal-point/ Share on other sites More sharing options...
ranjuvs Posted September 9, 2008 Share Posted September 9, 2008 use number_format $row2['total_ee'] = number_format($row2['total_ee'],2); Link to comment https://forums.phpfreaks.com/topic/123400-solved-how-to-get-value-for-2-decimal-point/#findComment-637351 Share on other sites More sharing options...
Mchl Posted September 9, 2008 Share Posted September 9, 2008 Or round($row2['total_ee'],2) Link to comment https://forums.phpfreaks.com/topic/123400-solved-how-to-get-value-for-2-decimal-point/#findComment-637369 Share on other sites More sharing options...
new_php85 Posted September 10, 2008 Author Share Posted September 10, 2008 use number_format $row2['total_ee'] = number_format($row2['total_ee'],2); thank you i got it hehehhehehhehehhe Link to comment https://forums.phpfreaks.com/topic/123400-solved-how-to-get-value-for-2-decimal-point/#findComment-638052 Share on other sites More sharing options...
new_php85 Posted September 10, 2008 Author Share Posted September 10, 2008 Or round($row2['total_ee'],2) thank you .... i got it hehehheehehhe Link to comment https://forums.phpfreaks.com/topic/123400-solved-how-to-get-value-for-2-decimal-point/#findComment-638057 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.