PHP not dividing correctly -
i have php code dividing 2 numbers pulled mysql database not computing correctly. when echo $comm , $total_fix individually, numbers correct. however, when echo division of 2 not correct answer. both numbers decimal(10,0) data type in database. below php code
$percent_comm = $comm / $total_fix; $percent_comm = number_format($percent_comm, 2, '.', ','); echo "<td align=\"center\">".$percent_comm."</td>"; here $comm = 2700, $total_fix = 75 $percent_comm computing 0.03 when should 36
from see on comments, getting $comm variable string comma, because of format. suggest convert formatted string valid number.
mean while i'll recomend this:
$comm = '2,700'; $comm = str_replace(',','',$comm); that remove comma number.
Comments
Post a Comment