Jump to content

Coding help


jrc713

Recommended Posts

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? :confused:

Every way I have tried isnt working

  PLEASEEEEEE HELP!!!

Using crimson editor

Link to comment
Share on other sites

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? :confused:

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!  :P

 

Just messing with ya, sort of.

Link to comment
Share on other sites

;) 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. :shrug:

P.S.  Sorry for posting in the wrong spot this is my first time in this forum.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.