Calculating data using PHP

Hi i have a small question with a task I am trying to complete

As part of a system that I am using I need to create a submission form that will allow me to enter in a metal from a list and do a calculation based on which metal is selected… for example:

If a user selects “silver” as a metal and then enters in a value of 200 grams, the system needs to calculate the price per gram for that metal and display back to the user how much they would get for their 200 grams of silver in GBP, USD and Euro’s.

The system should also only accept a weight in grams that is greater than zero and less or equal to 500 so i would need to enter some validation there.

Example:

metals.csv
Type of Metal Price Per Gram (GBP)
9 Carat Gold 11.97
Silver 0.49

=============================================

rates.csv
USD EUR
1.57 1.23

=============================================

How do you think I would go about achieving this??? I’m guessing I would need to get values from the .csv file again and then just calculate based on an amount from the user? and then displays the results for just that one metal in the different currencies??

I would image i need to have a php file that on submission calculate based on a variable value amount and then displays back the using the different currencies.

Thanks

Sponsor our Newsletter | Privacy Policy | Terms of Service