Greg Greg - 19 days ago 5
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

use number_format()

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