I have a very simple php program that I am working on for my computer science class but I am having a little trouble with it.
<?php
$numOfCards = '50'; //$_POST['numOfCards'];
$totalCost = 0.00;
if (numOfCards == '20')
{
$totalCost = $numOfCards*3.00;
}
else if (numOfCards == '50')
{
$totalCost = $numOfCards*2.50;
}
else
{
$totalCost = $numOfCards*2.00;
}
echo "<p>TOTAL COST FOR ".$numOfCards." CARDS: $".$totalCost."</p>";
?>
As you can see, I was originally getting my $numOfCards value from post data but have set it to 50 to prove a point. The issue is that this code as it is should go to the else if statement but instead it is going to the else statement. This results in totalCosts equalling $100 instead of $125.
Does anyone know what I am doing wrong? Thanks