Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2003
    Location
    mo
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    multiplication in php code

    Im having a problem writing a code for the following:

    i have a database insert call on a form page which takes the users ( id,quanity,cash amount ) now this is posted to a database table ,when they pay with there payment processor they are sent to the thankyou page where the code(" select from sales quanity,cash amount where id=$usrid") now problem is;

    each quanity = .02 as in (1=.02) if 3 then .06 .

    how do i write in math code to calulate the $quanity converted to (1=.02) to come up with the correct amount to put in update user table syntax?

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    <?php
    $cash 
    10;

    $quantity$cash 0.02;

    echo 
    $quantity;
    ?>

  • #3
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Although . is sometimes used in mathematics to denote multiplication, in PHP it's the string concatenation (no idea how to spell that) operator. That means, get two strings...
    Code:
    $string1 = "hello";
    $string2 = "world";
    $string3 = $string1 . " " . $string2;
    echo $string3;
    Would output 'hello world'. (Note that you could also write the third line as $string3 = "$string1 $string2";)

    * is the mulitplication operator.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!


  •  

    Posting Permissions

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