Results 1 to 4 of 4

Thread: Add multiple percentages to a starting figure by pulling stats from mysql.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2009
    Posts
    876

    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 :

    Name:  Screen Shot 2016-04-05 at 09.21.50.png
Views: 238
Size:  16.4 KB


    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

  2. #2
    Addicted Member Pc Monk's Avatar
    Join Date
    Feb 2010
    Posts
    188

    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
    Body Language tells the truth! even from the grave tsaeb eht morf gninnur ,nwod deaH
    All the big things started from little! teef my tsap evom sekans ,duol raor slluB
    Lietome.ir

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2009
    Posts
    876

    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.

  4. #4
    Addicted Member Pc Monk's Avatar
    Join Date
    Feb 2010
    Posts
    188

    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
    Body Language tells the truth! even from the grave tsaeb eht morf gninnur ,nwod deaH
    All the big things started from little! teef my tsap evom sekans ,duol raor slluB
    Lietome.ir

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width