Skip to main content
Inspiring
June 17, 2007
Question

Multiply Prices in PHP (k)

  • June 17, 2007
  • 3 replies
  • 323 views
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

This topic has been closed for replies.

3 replies

Inspiring
June 17, 2007
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
Inspiring
June 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)

Inspiring
June 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