$query=mysql_query($sql,$connect);
while($row = mysql_fetch_array($result3)){
echo "Total Profit = RM ". $row['SUM(profit)'];
echo "<br />";
}
echo"</br>";
echo "<b><u>Total Profit earned </u></b>" ;
echo"</br>";
$query1 = "SELECT country, SUM(profit) FROM `table 1` GROUP BY country";
$result1 = mysql_query($query1) or die(mysql_error());
while($row = mysql_fetch_array($result1)){
echo "". $row['country']. " = RM ". $row['SUM(profit)'];
echo "<br />";
}
我的代码有效但我需要将我的利润设置为2位小数。而不是RM 373037194.867713152
,我希望它将其显示为RM 373037194.87
。
答案 0 :(得分:0)
轻松圆()
echo "". $row['country']. " = RM ". round($row['SUM(profit)'], 2);
答案 1 :(得分:0)
使用round()
round($row['SUM(profit)'], 2); // round to two decimal places