Skip to main content
Participant
April 21, 2010
Question

cooking up a php echo

  • April 21, 2010
  • 2 replies
  • 420 views

Hi,

I have a mysql recordset that includes
'price_prd ' (item price - eg 14.95)
and
'amount_tax' (tax percentage to add - eg 17.5)

how can I show/ echo

<?php echo $row_rsPrd['price_prd']; ?> x 1.<?php echo $row_rsPrd[amount_tax]; ?>

price x 1.tax

...with only 2 deimal places?

much appreciated if anyone has the solution!

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

April 21, 2010

basic php math:

<?php

$price = $row_rsPrd['price_prd'];
$tax = $row_rsPrd[amount_tax];
$total = $price * $tax;
echo $total;
?>

Format $total by using number (or money) format function that was mentioned in the previous post.

Participating Frequently
April 21, 2010

Have a look at PHP's built in function number_format :

http://php.net/manual/en/function.number-format.php

HTH

-Rob B