-1
I have a script that calculates the total values and then demonstrates the total value in an echo. The problem is that the value is demonstrated without colons or commas, ex: 82700 to: 827.00 would like to convert it to decimal number but is not working yet.
<?php // Make a MySQL Connection $con = mysql_connect('', 'flash548_passhms', 'passhms');
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("flash548_passhms", $con);
$query = "SELECT month, SUM(overhead) FROM projections_sample GROUP BY month";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "Despesas". $row['month']. " R$". $row['SUM(overhead)']; //overhead
echo "<br />";
}
?>
What do you want is the same as this question? http://answall.com/questions/11301/formatteca-de-numeros-php
– Maniero
@mustache is basically this.
– the flash
Two tips: 1)
SELECT month, SUM(overhead) AS total FROM
so you can use$row['total']
. 2)$row['total']/100
returns what you want (however, without formatting). To format, I recommend seeing the answer given by @bigown– Bacco