Greg Greg - 1 year ago 89
MySQL Question

How to show two Decimal point

I've an online test result page, my code is:

echo ($r1['om']/$r['maxmarks']*100)." %";

Result showing: 61.764705882353 %

How to setup 61.76 % instead?

Answer Source

use number_format()

echo number_format($r1['om']/$r['maxmarks']*100,2)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download