Calculate PHP box goals

Asked

Viewed 56 times

-2

Hello, how could I do meta box calculation with PHP? I have a query in which returns all entries of the current month and then the sum.

Target: 200000.00 Total obtained so far: 15000.00

How could I get the completed percentage?

  • pctConcluded = Totalobtained / Meta * 100

  • Thanks, haha, that’s right.

1 answer

0


There is no secret, you will store the return of your query in a variable

$total = resultado_da_query;

Divide by goal and multiply by 100.

$meta = 200000;

$porcentagemDoMes = ($total / $meta) * 100;

If you want to display the result can do:

echo $porcentagemDoMes . "%";

Or you can incapsular this into a function and put the return of function:

return $porcentagemDoMes . "%";

  • Thank you very much!!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.