Shopping cart will not display shipping in right format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mony
Forum Newbie
Posts: 2
Joined: Mon Nov 17, 2003 7:53 pm

Shopping cart will not display shipping in right format

Post by mony »

:( Shopping cart will not display cost in the right format: pls help.
check it out at http://www.whiteliesdarktruth.com/purchase2.php

It displays 24.95
Shipping 3.60
Total Cost 28.55

the right display should be:

24.95
3.60
28.55

here is the code:

<table>
<tr>
<td width="250"><font color="#FfFfFf"><b>Product Name</b></font></td>
<td width="100"><font color="#FfFfFf"><b>Price</b></font></td>
<td width="100"><font color="#FfFfFf"><b>Qty</b></font></td>
<td width="100"><font color="#FfFfFf"><b>Total</b></font></td>
</tr>
<tr>
<td><font color="#FfFfFf">White Lies Dark Truth (Hardcover) </font></td>
<td><font color="#FfFfFf"><?php echo $bookPrice ?></font></td>
<td><font color="#FfFfFf"><?php echo $numBooks ?></font></td>
<td><font color="#FfFfFf"><?php echo $bookPrice*$numBooks ?></font></td>
</tr>
<tr>
<td></td>
<td></td>
<td ><font color="#FfFfFf"><b>Shipping</b></font></td>
<td><font color="#FfFfFf"><?php echo $arrShippingCost[$shippingIndexSelected] + $extraShipping*($numBooks-1); ?></font></td>
</tr>
<tr>
<td></td>
<td></td>
<td><font color="#FfFfFf"><b>Bill Total</b></font></td>
<td><font color="#FfFfFf"><?php echo $totalCost ?></font></td>
</tr>
</table>
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Firstly that link doesn't work. Secondly would you be a little more specific as to what you want. And welcome to the forums. :)
mony
Forum Newbie
Posts: 2
Joined: Mon Nov 17, 2003 7:53 pm

Follow Up

Post by mony »

Sorry for the mess up here is the right link:
http://www.monysingh.com/orders/purchase2.php

I want the shipping price to be displayed in the right format
at the moment it is showing up out of place.
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

The alignment looked fine via my browser. You may want to use this echo though to give you a trailing zero.

echo(number_format($totalcost, 2, '.', ''));

And the same for the rest of the dollar values. If you would like to read more on that go here.

http://au2.php.net/manual/en/function.number-format.php
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Or you can use [php_man]printf[/php_man] function. Btw there are example on currency formatting.
Post Reply