1 Attachment(s)
Add multiple percentages to a starting figure by pulling stats from mysql.
Hi all,
If I have the following
$startingfigure = "20,000";
$startdate = "2016-02-01";
and then in my database I have the following :
Attachment 136773
How can I make it add / subtract the percentages from the starting figure, but only add / subtract the percentages on any dates after the start date?
As everybody will have a different start date.
Any help would be appreciated.
Regards,
Jamie
Re: Add multiple percentages to a starting figure by pulling stats from mysql.
hi,
im not sure im following what u saying but if you are trying to get the precentage from the starting date you have to write a sql query :
Code:
$query = "SELECT `precentage` FROM `your table` WHERE date='yourdate'";
add / substract => what this mean exactly ? if you canexplain it simpler :confused:
Re: Add multiple percentages to a starting figure by pulling stats from mysql.
so basically using php code to add the percentages or subtract the percentages as an accumulative figure from the $startingfigure. So first add on 10.7% onto 20,000 and then minus 10.3% and update the startingfigure with the answer.
Re: Add multiple percentages to a starting figure by pulling stats from mysql.
its more like a math problem than php tho
so if u wanna add a percentage after ur get the percentage from database here is the math :
lets stick with your numbers first we gonna add 10.7%
to add a percentage to a number : 10.7 / 100 = 0.107
now you multiple it with 20,000 :0.107 * 20000 = 2140 => this is the result now if u want to add it to your starting figure its just a sum
Now if you wanna findout the remaining from u just minus it (for 10.3)
hope this helped
goodluck
:duck: