Hi,i was wondering if any of you here may be help me,bellow it is my code and having issues with displaying the change,it does not subtract “total amount from change,other then that it works it gives me the “subtotal” “quantity” “total amoun including tax” but “the change”. check the blue code
So,i was wondering if you can maybe help me with this little issue.thanks
i am asking cus i think you have more expirience then i do have i am a biggener,but i love programmming
——————————————————————————————————————-
<html>
<body>
<body bgcolor=”#777777”>
<form action=“cuenta.php” method=“post”>
<table border=“0”>
<tr bgcolor=”#cccccc”>
<td width=“150”>Item</td>
<td width=“15”>Quantity</td>
</tr>
<tr>
<td>Milk $3.00</td>
<td align=“center”><input type=“text” name=“milkqty” size=“3”
maxlength=“3” /></td>
</tr>
<tr>
<td>Beens $2.00</td>
<td align=“center”><input type=“text” name=“beenqty” size=“3”
maxlength=“3” /></td>
</tr>
<tr>
<td>Coke 2L $2.00</td>
<td align=“center”><input type=“text” name=“cokeqty” size=“3”
maxlength=“3” /></td>
</tr>
<tr>
<td colspan=“2” align=“center”><input type=“submit” name=“submit” value=“Make Order” /></td>
</tr>
</table>
<?php
echo “Order processed at: “. date( ‘h:i, l F Y’) .”“;
?>
<?php
//////////Retrieving the order
$milkqty = $_POST[‘milkqty’];
$beenqty = $_POST[‘beenqty’];
$cokeqty = $_POST[‘cokeqty’];
echo “Your order is as follows: “;
echo $milkqty.’ Milk
‘;
echo $beenqty.’ Cans of beens
‘;
echo $cokeqty.’ Coke 2L
‘;
////////////Total Amount
$totalqty = 0;
$totalqty = $milkqty + $beenqty + $beenqty;
echo “Items Ordered: ” . $totalqty .”</br>
“;
$totalamount = 0.00;
define(‘MILKPRICE’, 3);
define(‘BEENSPRICE’, 2);
define(‘COKEPRICE’, 2);
$totalamount = $milkqty * MILKPRICE
+ $beenqty * BEENSPRICE
+ $cokeqty * COKEPRICE;
echo “Subtotal: $”. number_format($totalamount,2) .”
“;
$taxrate = 0.09; // local sales tax is .09%
$cool = $totalamount * (1 + $taxrate);
$change = $paid - $cool;
echo “Total including tax: $”. number_format($cool,2);
?>
<form action=“cuenta.php” method=“post”>
Paid Amount: $ <input type=“text” name=“paid”/></p>
<input type=“submit” name=“submit”
value=“pay”/></p>
</form>
<?php
$paid = $_POST[‘paid’];
if ($paid < $cool) {
echo 'Wrong amount';
}else{
echo "Cash change is $". number_format($change,2);
}
?>
<hr>
</body>
</html>