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?
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?
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 . "%"
;