Hello all! 🙂
Please take a look at this code:
<?
echo "<p>Order processed at ";
echo date("F jS, H:i");
echo "<br>";
echo "<p>Your order is as follows:";
echo "<br>";
if( $totalqty == 0 )
{
echo "You did not order anything on the previous page!<br>";
}
else
{
echo $tireqty." tires<br>";
echo $oilqty." bottles of oil<br>";
echo $sparkqty." spark plugs<br>";
}
define("TIREPRICE", 100);
define("OILPRICE", 10);
define("SPARKPRICE", 4);
if($find == "a")
echo "<p>Regular customer.";
elseif($find == "b")
echo "<p>Customer referred by TV advert.";
elseif($find == "c")
echo "<p>Customer referred by phone directory.";
elseif($find == "d")
echo "<p>Customer referred by word of mouth.";
$totalqty = $tireqty + $oilqty + $sparkqty;
$totalamount = $tireqty * TIREPRICE
+ $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; // local sales tax is 10%
$totalamount = $totalamount * (1 + $taxrate);
$totalamount = number_format($totalamount, 2);
echo "Total including tax: $".$totalamount."<br>\n";
?>
Now, the problem is in the IF statements, specificly here:
if( $totalqty == 0 )
{
echo "You did not order anything on the previous page!<br>";
}
else
{
echo $tireqty." tires<br>";
echo $oilqty." bottles of oil<br>";
echo $sparkqty." spark plugs<br>";
}
if $totalqty equals zero, then that the if statement comes up, and if it doesn't, the else statement shows what you ordered etc, well it doesn't work :queasy:
Please help me fix this problem. Thank you.
JamesRP.