jrc713 Posted January 16, 2011 Share Posted January 16, 2011 So I put this in the wrong place so ill try again, I need to write a code to add the price of five items with a subtotal, with tax, and then a grand total. What is the best way to do this? Every way I have tried isnt working PLEASEEEEEE HELP!!! Using crimson editor Quote Link to comment https://forums.phpfreaks.com/topic/224584-coding-help/ Share on other sites More sharing options...
trq Posted January 16, 2011 Share Posted January 16, 2011 Post your problematic code and a dcesription of the actual problem. Quote Link to comment https://forums.phpfreaks.com/topic/224584-coding-help/#findComment-1160137 Share on other sites More sharing options...
Zurev Posted January 16, 2011 Share Posted January 16, 2011 So I put this in the wrong place so ill try again, I need to write a code to add the price of five items with a subtotal, with tax, and then a grand total. What is the best way to do this? Every way I have tried isnt working PLEASEEEEEE HELP!!! Using crimson editor <?php $item1 = floatval($_POST['item1']); $item2 = floatval($_POST['item2']); $item3 = floatval($_POST['item3']); $item4 = floatval($_POST['item4']); $item5 = floatval($_POST['item5']); $tax = ".10"; // 10% if (isset($_POST['submit'])) { $subtotal = $item1+$item2+$item3+$item4+$item5; $taxAmount = $subtotal * $tax; $total = $subtotal+$taxAmount; echo "Subtotal: $subtotal<br> Tax: $taxAmount<br> Total: $total"; } ?> <style> input{display:block;} </style> <form action="" method="post"> <input type="text" name="item1" /> <input type="text" name="item2" /> <input type="text" name="item3" /> <input type="text" name="item4" /> <input type="text" name="item5" /> <input type="submit" value="Add" name="submit" /> </form> Not great, but it works quick. Tell your teacher I sayz hi! Just messing with ya, sort of. Quote Link to comment https://forums.phpfreaks.com/topic/224584-coding-help/#findComment-1160144 Share on other sites More sharing options...
jrc713 Posted January 16, 2011 Author Share Posted January 16, 2011 Thank you so much for you're help you are awesome. The teacher did give some examples but the editor that i am using isn't showing color so I can't tell if what I am typing is correct or not. This is my first class and I am sooooo green when it come to writing code. P.S. Sorry for posting in the wrong spot this is my first time in this forum. Quote Link to comment https://forums.phpfreaks.com/topic/224584-coding-help/#findComment-1160148 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.