php sql percentage of rows

  • Posted on August 31, 2014
  • xdficoAsked by xdfico

Hello i have problem, i want to my php script calculate percent of ex.

row 1 have ‘dmg’ value ‘62’ row 2 have ‘dmg’ value ‘38’

now, script need sto calculate this etc:

row 1 is: 62% of total ‘dmg’

and row 2 is: 38%

the percent need to be max. 100% ex. ‘dmg’ of row 1 can be 6200 and ‘dmg’ of row 2 can be 3800 but percent need to be 100% max…

any help? i tryed scripts but no one helps … thanks!! try.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi! Your question is a little unclear. In php you can calculate a percentage like you normally would. For instance, 3000 is 48.39% of 6200:

# php -a
php > $n = 3000;
php > echo (($n / 6200) * 100)."\n";

Maybe if you could be more specific about the problem you’re facing, we can help you better.