Ok, I may have to rethink this....I have everything set up in Excel fine, but trying to get my thoughts on the math carried over to PHP is where I am losing my mind maybe. The math should be as follows:
Example: Coin cost is $100.00 + $5.00 a/h fee = $117.00 (user input)
American Gold Eagle = 1/10th oz gold (user input)
Take your live gold spot price (which is now $845.30) and multiply your gold weight times your spot price. (user input)
$845.30 X .10 (1/10th oz) = $84.53 Your $84.53 is your gold content value inside the coin. This is how much $ value you have in gold according to golds spot price. If golds spot price was $800.00, you do the same multiplication times $800.00. .10X $800 = $80.00
$117.00 - $84.53 = $32.47
Your $32.47 is your premium paid including your s/h fees.
Divide your premium cost by your total cost gives your percentage premium paid over gold content.
$32.53 / $117.00 = .2775% premium or 28% premium.