Web Hosting Talk







View Full Version : 2checkout Deduction Script


Typhoon
05-02-2002, 01:27 PM
I got fed up with running the numbers through a calculator so I made a script where you just enter the price in the URL and it deducts 2checkouts 5.5% and 0.45 cents.

any improvements would be great :)

<?php

$output2 = $price/100;
$output3 = $output2*5.5;
$output4 = $price-$output3;
$output5 = $output4-0.45;

print "The price is $".($output5)."";
?>

Maybe getting the script to round off to the nearest cent?

The script works as so -
http://www.yourdomain.com/price.php?price=5.99

My first PHP script :D

Smirks
05-02-2002, 01:38 PM
Of course you could just have:


<?php
$output = ($price - (($price/100)*5.5)) - 0.45;
print "The price is $".($output)."";
?>

;)

Typhoon
05-02-2002, 01:39 PM
Ah cool :D
Any suggestions on rounding it off to the nearest cent? (2 d.p)

acidHL
05-02-2002, 04:18 PM
Use:
$<? printf ("%01.2f", "$output"); ?>

Or somthing along those lines.