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

Multiply Prices in PHP (k)

LEGEND ,
Jun 17, 2007 Jun 17, 2007
I have the price of my items stored as a decimal (11,2). On my page, I want
to be able to multiple those prices by a quantity. I have used this code:

<?php $a=$row_rsPrices['Price_Wholesale']; $b=10; $c=$a*$b; echo $c?>

Price_Wholesale in this example is 24.95 it is multiplied by $b which is 10
The result is 249.5

I want it to be a price, so my question is, how do I make it show the zero?
249.50

-Kirk

TOPICS
Server side applications
324
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
LEGEND ,
Jun 17, 2007 Jun 17, 2007
On Sun, 17 Jun 2007 11:25:55 -0400, "W. Kirk Lutz"
<wkirklutz@verizon.net> wrote:

>Price_Wholesale in this example is 24.95 it is multiplied by $b which is 10
>The result is 249.5
>
>I want it to be a price, so my question is, how do I make it show the zero?
>249.50

<?php
$a=$row_rsPrices['Price_Wholesale'];
$b=10;
$c=$a*$b;
echo number_format($c,2);
?>

Gary
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
LEGEND ,
Jun 17, 2007 Jun 17, 2007
Thanks, that did the trick.

-Kirk


On 6/17/07 12:43 PM, in article 94pa73l6b69208vd9edfb371168be2n787@4ax.com,
"Gary White" <reply@newsgroup.please> wrote:

> number_format($c,2)

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
LEGEND ,
Jun 17, 2007 Jun 17, 2007
LATEST
On Sun, 17 Jun 2007 12:55:49 -0400, "W. Kirk Lutz"
<wkirklutz@verizon.net> wrote:

>Thanks, that did the trick.

You're welcome.

Gary
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