Hi everybody,
I just started learning PHP and was asked to write a BMI calculator. I did all that but now I'm stuck with an if ... elseif that doesn't seem to want to work. I'm sure it's just a syntax error but could somebody look over it and see what I've done wrong with my if ... elseif? Remember, I'm new to this so my code isn't optimized or clean. Thanks in advance if you can help me out!
<?php
$fname = $_POST['fname'];
$weight = $_POST['weight'];
$feet = $_POST['feet'];
$inch = $_POST['inch'];
$inches = ($feet * 12) + $inch;
$total = $weight * 703 / ($inches * $inches);
echo "First Name: ".$fname;
echo "<br>";
echo "Weight (lb): ".$weight;
echo "<br>";
echo "Height (ft/in): ".$feet;
echo " feet ".$inch;
echo " inches";
echo "<br>";
echo "<br>";
echo "Your BMI is ".number_format($total, 2);
echo "<br>";
echo "<br>";
if ($total <= 18.5)
echo "You are underweight";
else if (($total >= 18.6) && ($total <= 24.9))
echo "You are at normal weight";
else if (($total >= 25) && ($total <= 29.9))
echo "You are overweight";
else if ($total >= 30)
echo "You are obese";
?>