Hello, I need to do the following math operation in PHP: (order total x 6.5%) + 4.50 (the order total needs to be multiplied by 1.065 before adding the 4.5) The order total variable is from a POST: $_POST["price"] Can any show me the correct syntax? Thanks! -Adam
I suppose this would work: <?php $ordertotal = $_REQUEST['price']; $total = (($ordertotal * 1.065) + 4.5); ?> PHP: Good luck, Lee.
$total = ($_POST["price"] * 1.065) + 4.5; $total = number_format($total, 2) PHP: You really don't need the parenthesis around the multiplication operation since the multiplication operator has greater precedence than the addition operator. But I always use parenthesis anyway. It's up to you. It could also be: $total = $_POST["price"] * 1.065 + 4.5; PHP: Learn what the number_format function does here: http://us2.php.net/number_format
OK, thank you very much. That's what I needed! I forgot that I needed to round it to two decimal places, too. Thanks! -Adam