Hey guys, Im trying to code a body shape calculator using PHP maths functions, its giving me a headache:confused:.
I have tried coding the body shape calculator with the following values, but it jus gives undesirable results:yawn:. Is it my code or the problem is with the ratios?
Apple: 0.8 waist/hip ratio with bust and hips within 2 inches of each other.
Hourglass: 0.7 waist/hip ratio with bust and hips within 2 inches of each other.
Strawberry: 0.8 waist/hip ratio with bust more than 2 inches bigger than hips.
Pear: 0.7 waist/hip ratio with hips more than 2 inches bigger than the bust.
Rectangle: waist/hip ratio same with bust
and here is the PHP code:
<?php //if(isset($_POST['submit'])){
extract($_POST);
$memberid = $_SESSION['sess_userID'];
//$loginid = $_SESSION['SESS_LOGIN'];
//$membername = $_SESSION['SESS_member_NAME'];
/*if ($_SESSION['sess_userID'] == NULL){
redirect("../login.php");
}*/
$waist = $_POST['waist'];
$hips = $_POST['hips'];
$ratio = $waist/$hips;
//print_r($_POST);
if (($ratio == 0.8) && (abs($bust - $hips) <= 2)){
$shape = 'apple';
echo "Your bodyshape is apple";
}
elseif (($ratio == 0.8) && (abs($bust - $hips) > 2)){
$shape = 'strawberry';
echo "Your bodyshape is strawberry";
}
elseif (($ratio == 0.7) && (abs($bust - $hips) <= 2)){
$shape = 'hourglass';
echo "Your bodyshape is hourglass";
}
elseif (($ratio == 0.7) && (abs($hips - $bust) > 2)){
$shape = 'pearl';
echo "Your bodyshape is pearl";
}
else {
$shape = 'rectangle';
echo "Your bodyshape is rectangle";
}
if (isset($_SESSION['sess_userID']))
$insert = $db->query("UPDATE member SET m_shape = '{$shape}' WHERE m_id = {$memberid}");
//}?>
I recently came across the following Body shape ratios, Im thinking of using them also since the above ones seems to be failing me.
Apple:
WHR (Waist-to-Hip Ratio) on or above 0.8
Pear: 0.7
WHR (Waist-to-Hip Ratio) under 0.8
Hourglass:
Bust and hips are basically the same circumference - though the bust can be up to 1" larger than the hips. The waist is then 9" or more smaller than the bust.
Triangle
The bust is 3.6" larger than the hips and the waist is less than 9" smaller than the bust.
Rectangle:
Where the bust and hips are basically the same circumference. The waist is less than 9" smaller than the bust.
Hope someone will be of great help. Thanks