- Joined
- Jul 27, 2006
- Messages
- 394
- Reaction score
- 23
- Points
- 18
- Location
- Berkshire, Uk
- Your Mac's Specs
- 15.4" MBP Sep 09, 2.66Ghz C2D, 4Gb Ram, 320Gb HDD 7200rpm, 10.6.x / iPod Touch 8Gb
This is confusing me a little.. basicly ive got a script that will get the total of a quantity then add the VAT ontop of that, the script then shows the Total with VAT and without VAT, working out the VAT alone is simple and trying to show the VAT in the right format is annoying me!
First i rouned the nearest number with round () function.
the VAT alone is £629.75 but is showing like this 62975.0
but isnt showing the amount correct.. here is my entire code and an example sum with preview
http://www.bloogrape.co.uk/test/maths.php
I have fiddled around with the format with no luck and only errors
Any help would be great
First i rouned the nearest number with round () function.
the VAT alone is £629.75 but is showing like this 62975.0
but isnt showing the amount correct.. here is my entire code and an example sum with preview
http://www.bloogrape.co.uk/test/maths.php
PHP:
<?php
$quantity = 30;
$price = 119.95;
$vat = 17.5;
# Code belows adds the quantity and then the VAT
$total1 = $quantity * $price;
$total = $quantity * $price;
$total = $total + ($vat / 100 * $total);
# then the number is stripped in to 2 points
$total = number_format ($total, 2);
# working out the vat cost only
$vat1 = 100 / 100 + $vat * $total1;
$vat1 = round ($vat1);
$vat1 = number_format ($vat1, 1, '.', '');
echo 'You are purchasing <b>', $quantity, '</b> widget(s) at a cost of <b>£', $price. '</b> each. Total price: £', $total1, ' With VAT Total: £', $vat1, '<br /> the total comes to <b>£', $total, '</b>.';
?>
I have fiddled around with the format with no luck and only errors
Any help would be great