Body Mass Index – Behind the Scenes

Originally for my post on the Body Mass Index (BMI), I wanted to include a BMI calculator directly in the post.  I found a WordPress plugin, PHP Code for Posts that allowed me to use PHP code in the post and coded the calculator.  Unfortunately, when I tried to put the calculator on the page,  I ran into an issue with how the variables are passed from the form to the function that handles the calculations.  The code works on it’s own, but embedded in a post it fails.  I ended up making a link to the URL where I had tested the calculator.  I’m hoping to find a better solution in the future.

Here’s the code, in case you’re intersted (formatted with Preserve Code Formatting). Normally, I’d pull the style sheet and HTML into their own files, but for the purposes of displaying the code I have them all together.

 



Body Mass Index (BMI) Calculator for Adults

'; function bmiForm() { echo '



'; if ((empty($weight)) && ($_POST['done'] == 'y') || (empty($feet)) && ($_POST['done'] == 'y') || (empty($inches)) && ($_POST['done'] == 'y')) echo '

Please complete all fields above.

'; } function bmiResult() { global $weight, $height, $feet, $inches; $BMI = number_format((($weight / ($height * $height)) * 703), 1, '.', ''); echo '

Your Body Mass Index (BMI) is: ' .$BMI. '

'; echo '

Based upon a height of ' .$feet. ' feet, ' .$inches. ' inches and a weight of ' .$weight. ' pounds

'; if ($BMI <= 18.5) { echo '

Your BMI falls in the "Underweight" category.

Understanding your BMI: BMI is not intended to diagnose a problem, but to indicate when follow up with a healthcare professional is a good ideas. It is possible for a person to be healthy with a BMI that falls outside of the Normal range. However, you should consider seeking the opinion of a healthcare professional or registered dietitian.

'; } elseif (($BMI > 18.5) && ($BMI <= 24.9)) { echo '

Your weight is normal.

Understanding your BMI: BMI is not intended to diagnose a problem, but to indicate when follow up with a healthcare professional is a good ideas. A BMI within the Normal range is associated with reduced risk of diseases, including diabetes and high blood pressure, which are more common in overweight and obese individuals.

'; } elseif (($BMI >= 25) && ($BMI <= 29.9)) { echo '

Your BMI falls in the Overweight category.

Understanding your BMI: BMI is not intended to diagnose a problem, but to indicate when follow up with a healthcare professional is a good ideas. A BMI within the Overweight range is associated with increased risk of disease, including diabetes and high blood pressure. While it is possible to be healthy with this BMI, you should consider seeking the opinion of a healthcare professional or registered dietitian.

'; } elseif ($BMI >= 30) { echo '

Your BMI falls in the Obese category.

Understanding your BMI: BMI is not intended to diagnose a problem, but to indicate when follow up with a healthcare professional is a good ideas. A BMI within the Obese range is associated with increased risk of disease, including diabetes and high blood pressure. While it is possible to be healthy with this BMI, you should consider seeking the opinion of a healthcare professional or registered dietitian.

'; } else { echo "

Sorry, something went wrong

"; } } if ((isset($_POST['done'])) && ($_POST['done'] == 'y') && ($_POST['inches'] != NULL) && ($_POST['weight'] != NULL) && ($_POST['feet'] != NULL)) { bmiResult(); } else { bmiForm(); } echo '

This calculator is intended for use by individuals over 20 years of age. More Information about BMI from the Centers for Disease Control and Prevention

'; ?>

Body Mass Index

Body Mass Index (BMI) is frequently misinterpreted.  Looking around the internet you’ll find plenty of articles and blog posts talking about its failures.  Often, the key complaint will be that it can misidentify very muscular individuals as being obese. Additionally, BMI doesn’t take frame size into account, which can be another important factor in assessing weight.  The complaints against BMI usually stems from a misunderstanding of the intended use of BMI.  The intent is not to attach a specific label to a individual,  rather it is used to evaluate populations, and as a screening tool in healthcare settings.

As screening tool, it’s intended to identify individuals who may be in need of further assessment.  In the hospital setting, dietitians may use BMI as one criteria for taking time to do a more in-depth review of the patient’s record.  The 2008 study Accuracy of Body Mass Index to Diagnose Obesity In the US Adult Population found that, when evaluating obesity,  the BMI has 95% specificity for men and 99% specificity for women.  This means that if the BMI indicates obesity its highly likely to be correct.  This is a great counter-argument against those who bring up false positives like the elite athlete.  The sensitivity of the BMI is low, so using it  as the sole evidence to rule out obesity would be a problematic.

So, what does the Body Mass Index say for you?