googlit Posted June 25, 2010 Share Posted June 25, 2010 hi, im trying to edit my shopping basket code to display prices ex-vat (17.5%) and to display the vat amount What i have so far: Price of an item = $Price quantity of an item = $qty //sum to display vat amount - reduced to two decimal places £'.round(($Price / 47) * 7, 2).' //sum to display price ex vat - reduced to two decimal places £'.round($Price / 1.175, 2).' what i need to do now is display a sub-total with the following: total price ex-vat - - Price minus VAT * Qty total vat amount - - for this i had £'.round((($Price / 47) * 7) * $qty, 2).' which didnt work any help would be received well....... Thanks Quote Link to comment https://forums.phpfreaks.com/topic/205882-php-maths-issueplease-help-a-noob-ish/ Share on other sites More sharing options...
Coders2018 Posted June 26, 2010 Share Posted June 26, 2010 I've just started learning PHP and bought a book and the first thing we had to do was build a shopping cart. We did also happen to have a sub-total included as well. This is the code I'm using for my Sub-total value I've edited it so that it fits the variable name you have given your total price variable. echo "Sub-total: $".number_format($Price,2)."<br />"; Quote Link to comment https://forums.phpfreaks.com/topic/205882-php-maths-issueplease-help-a-noob-ish/#findComment-1077448 Share on other sites More sharing options...
googlit Posted June 26, 2010 Author Share Posted June 26, 2010 I've just started learning PHP and bought a book and the first thing we had to do was build a shopping cart. We did also happen to have a sub-total included as well. This is the code I'm using for my Sub-total value I've edited it so that it fits the variable name you have given your total price variable. echo "Sub-total: $".number_format($Price,2)."<br />"; Thanks but all that is is a formated Price from the session with two decimal points, i need something a bit more technical..... which book are you reading? may be woth a look..... thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/205882-php-maths-issueplease-help-a-noob-ish/#findComment-1077452 Share on other sites More sharing options...
Coders2018 Posted June 26, 2010 Share Posted June 26, 2010 Ok no problems then. Here is the link for the book that I'm reading - http://www.amazon.co.uk/PHP-MySQL-Development-Developers-Library/dp/0672329166/ref=sr_1_2?ie=UTF8&s=books&qid=1277513297&sr=8-2 It's been good so far and I'm learning quite a lot from it. Quote Link to comment https://forums.phpfreaks.com/topic/205882-php-maths-issueplease-help-a-noob-ish/#findComment-1077461 Share on other sites More sharing options...
sasa Posted June 26, 2010 Share Posted June 26, 2010 try $price_ex_VAT = $price * 40 / 47; Quote Link to comment https://forums.phpfreaks.com/topic/205882-php-maths-issueplease-help-a-noob-ish/#findComment-1077646 Share on other sites More sharing options...
googlit Posted June 29, 2010 Author Share Posted June 29, 2010 try $price_ex_VAT = $price * 40 / 47; Thanks sasa, that worked well, not sure why i didn't think off that.... Quote Link to comment https://forums.phpfreaks.com/topic/205882-php-maths-issueplease-help-a-noob-ish/#findComment-1078864 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.