Click here to Skip to main content
15,904,497 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi!

Revision Question: Write a PHP program to calculate and display cost of the products using the formula: Cost=TAX * (quantity*unit price). Assume the TAX is a constant 0.16. The values of quantity and unit price are sent as form values to the back end for server side processing.

I have come a cross the above question in a list of other questions that I've managed to resolve, and need your technical guidance on the best approach to adopt.

Note: The guidance I need is basically on the logical sequence of tasks/approach that I need to follow, but NOT the entire front and back-end coding as this will not enable me think. I have exam for Application for Internet Programming mid next week...but I feel there is more on this question I'm yet to grasp ,and need help in approaching as it was part of areas we were suppose to read on ourselves(not fully covered during lecture time). If there is any online link/resource/tutorial that can offer me guidance , I'll appreciate

**************

By guidance, I needed to know if there is need to first create a database with product table...or if this is not necessary. For instance, I would have wished that users only key in their names but other items should be readily available for selection using other form features...and even before clicking submit Button, totals are to be displayed...well for now,basic data entry and viewing output will be a step for me.

I have done html coding as well as php(below). Where to insert the formula is still a challenge and need your support ...yes, this is my 2.5 month and my knowledge is still pretty elementary.... and sometimes translating lecture notes into practical application takes time... but I'm catching up.Starting to ride a bike may be easy for an experienced rider...for a learner, it may seem an uphill task...:)

Thanks you all.

What I have tried:

HTML
//client side coding

<br>
<h1>Enter Purchase Details</h1>


Firstname:<br><br>
Last tname: <br><br>
Product Name: <br><br>

Quantity: <br><br>
Unit Price: <br><br>

Tax Charge....// I think this requires a formular (0.6*Unit Price)...

Total Cost(USD): <br><br>





**************************************************************************
//client end coding

<body bg="yellow>
<?php echo<Client Details:";?><br>
<font color="black">First name:  </font><?php echo$-POST["a"];?><br>
<font color="black">Last name:  </font><?php echo$-POST["b"];?><br>
<font color="black">Product Name:  </font><?php echo$-POST["c"];?><br>
<font color="black">Quantity:  </font><?php echo$-POST["d"];?><br>
<font color="black">Unit Price:  </font><?php echo$-POST["e"];?><br>
<font color="black">Tax Charge  </font><?php echo$-POST["O.6"];?><br>
<font color="black">COST):  </font><?php echo$-POST["e"];?><br>
($_POST["0.6"]*($_POST["e"]);?><br>// need help inserting the formular/formular function in php..



</html
Posted
Updated 5-Apr-18 12:46pm
v5
Comments
Christiaan van Bergen 4-Apr-18 19:15pm    
Wow, you want us to do your homework? Please tag it with 'Homework'.
Richard MacCutchan 5-Apr-18 5:02am    
Your inputs need to be 'quantity' and 'unit price'. From there you can calculate total net cost, tax, and gross cost. Simple mathematics.

1 solution

The question, as you have posed it, requires some of the most elementary of computer operations (multiply a few numbers and save the value).

Now you want the processing on the server side, via a form.

If you want to do more than just waste your time in the course, and perhaps get a passing grade without learning anything, you need to start learning something!

Try:   PHP[^] and HTML Forms[^]

Unless today is the first day of classes, you do not appear to have put much into the course. Why are you taking it?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900