jeg har flg. kode
___________________________________________________
<html>
<head>
<title>Auto Parts</title>
</head>
<body>
<h1>Autoparts</h1>
<h2>Order Results</h2>
<?
echo "<p>Order processed at ";
echo date("H:i, jS F");
echo "<br />";
echo "<p>Your order is as follows:";
echo "<br />";
$totalqty = 0; //$totalqty = 0;
$totalamount = 0.00; //$totalamount = (double)$totalqty;
define("TIREPRICE", 100);
define("OILPRICE", 10);
define("SPARKPRICE", 4);
$totalqty = $tireqty + $oilqty + $sparkqty;
if( $totalqty == 0 )
{
echo "You did not order anything on the previous page!<br />";
}
else
{
if( $tireqty < 10 )
$discount = 0;
elseif($tireqty >=10 && $tireqty <= 49)
$discount = 0.05;
elseif($tireqty >=50 && $tireqty <= 99)
$discount = 0.1;
elseif($tireqty > 100 )
$discount = 0.15;
echo $tireqty." tires<br />";
if ( $oilqty > 0)
echo $oilqty." bottles of oil<br />";
if( $sparkqty >0 )
echo $sparkqty." spark plugs<br />";
}
$totalamount = $tireqty * (TIREPRICE - (TIREPRICE * $discount))
+ $oilqty * OILPRICE + $sparkqty * SPARKPRICE;
$totalamount = number_format($totalamount, 2);
echo "<br />\n";
echo "Items ordered: ".$totalqty."<br />\n";
echo "Subtotal: $".$totalamount."<br />\n";
$taxrate = 0.10;
$totalamount = $totalamount * (1 + $taxrate);
$totalamount = number_format($totalamount, 2);
echo "Total including tax: $".$totalamount."<br />\n";
?>
</body>
</html>
_____________________________________________________
Det virker fint, så længe inputs'ne inputs'ne ikke overstiger 10,
hvis jeg skriver 11 får jeg altid total amount=$1.10.... hvorfor
det...?
på forhånd tak
Brian Danielsen
--
Vil du lære at kode HTML, XHTML, CSS, SSI, ASP eller ASP.NET?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! =>
http://www.html.dk/tutorials