Results 1 to 7 of 7

Thread: [PHP] Maths ...

  1. #1
    Join Date
    Aug 2000
    Posts
    2,750

    [PHP] Maths ...

    Hi,

    I'm having a total blonde moment, I'm doing the following:

    PHP Code:
                       $a=$trader[value];
                            
    $b=17;
                            
    $c=27;
                            
    $add1 = ($a+$b);
                            
    $add_up = ($add1+$c); 
    This works, but what I want is for $b to be 17% - whatever I try seem's to cause problems. Any ideas?

  2. #2
    Join Date
    Mar 2005
    Posts
    31
    Huh? What are you trying to do?

  3. #3
    Join Date
    Aug 2000
    Posts
    2,750
    OK, Maybe I should of explained that bit :-)

    I'm building an addon for my site that allows you to buy members.

    $trader[value] - is the existing value in the database.

    $b - is intended to add 17% to the existing points total. This 17% will be different each tranasaction as it adds to whatever the $trader[value] amount is.

    $c - adds a sales like tax of 27 points, this is the same in all transactions.

  4. #4
    Join Date
    May 2007
    Location
    United States
    Posts
    595
    Something like

    PHP Code:
    $a $trader[value];
    $b $a*0.17// *0.17 = 17%
    $c 27;
    $add1 $a+$b;
    $add_up $add1+$c 


  5. #5
    Join Date
    Aug 2000
    Posts
    2,750
    Thanks Paul,

    I used this:

    PHP Code:
                            $a $trader[value];
                            
    $b $a*0.17// *0.17 = 17%
                            
    $c 27;
                            
    $add1 $a+$b;
                            
    $add_up round($add1+$c); 
    As I didn't want it to show as 158.04 now shows as 158

    Thanks.

  6. #6
    Join Date
    Jul 2007
    Location
    United States
    Posts
    19
    As a quick note, multiplying by 1.17 will get the total with 17% added on. Something like this works too.

    PHP Code:
    $add_up round($trader[value]*1.17+27); 

  7. #7
    Join Date
    May 2007
    Location
    United States
    Posts
    595
    Quote Originally Posted by ZackN View Post
    As a quick note, multiplying by 1.17 will get the total with 17% added on. Something like this works too.

    PHP Code:
    $add_up round($trader[value]*1.17+27); 
    True, I just wanted to follow the OP's format of doing it


Posting Permissions

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