Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cooking up a php echo

Explorer ,
Apr 21, 2010 Apr 21, 2010

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!

TOPICS
Server side applications
417
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 21, 2010 Apr 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 21, 2010 Apr 21, 2010
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines