Calculate PHP box targets

-2

Hello, how could I make cash goal calculation with PHP? I have a query in which returns all the entries of the current month and then adds them.

Target: 200000.00 Total Obtained So Far: 15,000.00

How could I get the percentage of completed?

    
asked by anonymous 23.06.2018 / 03:28

1 answer

0

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 you can do:

echo $porcentagemDoMes . "%";

Or you can infer this in a function and put the function return:

return $porcentagemDoMes . "%" ;

    
23.06.2018 / 03:46