View Full Version : multiplication in php code

gary pepper
12-26-2003, 07:22 PM
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?

12-26-2003, 09:45 PM
$cash = 10;

$quantity= $cash * 0.02;

echo $quantity;

12-27-2003, 11:06 AM
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...
$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.