Ok here is complete code …
form action=" " method=“post”>
I don’t know why he doesn’t show input feilds code here
here is two input fields Price and Discount
if(isset($_POST[‘calculator’])){
$price = $_POST[‘price’];
$discount = $_POST[‘discount’];
}
if($price <= 22) {
$price = 128.13;
}
echo "<font size=5><center>Price: ".$price."</center>";
echo "<font size=5><center>Discount: ".$discount."</center>";
echo "<font size=5><center>Result: ".$result = $sum=$price+$discount;"</center>";
}
?>
As u can see i have two input fields if, i enter in first field numbers between 1 and 22 result is 128.13,now i need discount on that result if i enter 1 in second field, result need to be 128.13 - 1.28,
i found solution for that and works fine with this code
if($discount == 1 && $price < 23) {
$discount = -1.28;
} elseif ($discount == 2 && $price < 23) {
$discount = -2.56;
} elseif ($discount == 3 && $price < 23) {
$discount = -3.84;
} else {
$discount = 0;
}
but since I have a huge price list it is quite hard to type 99 if statemant for every price,basicly for every 1% i need to code elseif statement…i hope there is another way to do this or shorter way…Tnx for help.