Php vat calculation

Hi there,

I am building an online shop that pulls records from a MYSQL database.

The problem i have is that the prices have been input without vat, but I want to display the price with vat included.

I am very new to php and believe it should be possible to do this.

My database table is called stock list, so the price field is ‘stock list.price’.
Code in dreamweaver for price is <?php echo $row_Recordset1[‘price’]; ?>

Any clues as to the best way to do this short of trawling through the database changing all the prices ?

Thanks for your help.

You will need to multiply your value by 1.175.


<?php echo (($row_Recordset1['price'])*1.175); ?>

Note: You could write some code that read your table, multiplied all the values by 1.175, saved the results to another tempory table, deleted the first table and renamed the tempory table to your original table name.
Swings and roundabouts - at least as you have it now if the VAT rate changes you only have one value to change.

Thanks Rubble that works a treat.

Can you get it to round up to the nearest penny as well?

The site is if you want to have a look.
Its got a long way to go, but im pretty happy with it so far.

Thanks again for your help.


Not sure if this will work

<?php echo (round(($row_Recordset1['price'])*1.175), 2); ?>


The site is looking good - a lot of work there.

Note: If above example does not work I would do it in two steps:

$value = (($row_Recordset1['price'])*1.175);  
echo round($value, 2);

That didnt work unfortunately. think i need to format the number first.
Hmmmm, Can of worms comes to mind, Have had a quick look at those links.
Gonna take a bit more study i think.

Thanks again for your help Rubble much appreciated.

Will let you know if i find a solution.

Sorry Rubble had to turn in,

Your last piece of code works perfectly. Thank you very much. I think I would have got there in the end, but it would probably have taken me a few days.

Colonel bogey