Hi,
I was wondering if anyone can point me in the right direction as i am not able to align the text boxes beside there title’s. I was to get 2 out of 3 boxes to line up but cant seem to be able to get the last textbox to align correctly and also i can’t center a title that i need to have centered. Below is the code and screenshot of my issue. Thanks in advance for any suggestions/ help with getting this fixed as i am still trying to learn PHP coding.
[php]
<?php session_start(); $firsttext="Your Body Mass Index (BMI) is %%BMI%%"; ?> .calculator_div { font-size:16px; font-family:verdana, arial, sans-serif; border:1px solid #51739B; padding:25px; margin-top:0px; margin-bottom:0px; margin-right:160px; margin-left:260px; width:350px; } .calculator_div label { width: 8em; float: left; text-align: center; margin-right: 0.5em; display: block } <?php if(!empty($_POST['calculator_ok'])) { // set vars in session foreach($_POST as $key=>$var) { $_SESSION['bmi_calc_'.$key]=$var; } if($_POST['system']=='english') { $height=$_POST['height_ft_en']*12+$_POST['height_in_en']; $bmi=($_POST['weight_en']*703) / ($height*$height); } else { $height=$_POST['height_met']/100; $bmi=$_POST['weight_met'] / round(($height*$height),2); } $bmi=number_format($bmi,1,".",""); // prepare message for the user if($bmi<=18.5) { $bmimsg="Underweight"; } if($bmi>18.5 and $bmi<=24.9) { $bmimsg="Normal"; } if($bmi>=25 and $bmi<=29.9) { $bmimsg="Overweight"; } if($bmi>=30) { $bmimsg="Obese"; } // what is the weight range if($bmimsg!='Normal') { if($_POST['system']=='english') { $lowerlimit=number_format(( 18.5 * ($height*$height) ) / 703); $lowerlimitkg=number_format($lowerlimit*0.453,1,".",""); $upperlimit=number_format(( 24.9 * ($height*$height) ) / 703); $upperlimitkg=number_format($upperlimit*0.453,1,".",""); } else { $lowerlimit=number_format( 18.5 * ($height*$height) * 2.204 ); $lowerlimitkg=number_format(18.5 * ($height*$height),1,".",""); $upperlimit=number_format( 24.9 * ($height*$height) * 2.204 ); $upperlimitkg=number_format(24.9 * ($height*$height),1,".",""); } } //prepare texts $firsttext=str_replace("%%BMI%%",$bmi,$firsttext); $firsttext=str_replace("%%BMIMSG%%",$bmimsg,$firsttext); $lowertext=str_replace("%%LOWERLIMIT%%",$lowerlimit,$lowertext); $lowertext=str_replace("%%LOWERLIMITKG%%",$lowerlimitkg,$lowertext); $lowertext=str_replace("%%UPPERLIMIT%%",$upperlimit,$lowertext); $lowertext=str_replace("%%UPPERLIMITKG%%",$upperlimitkg,$lowertext); $uppertext=str_replace("%%LOWERLIMIT%%",$lowerlimit,$uppertext); $uppertext=str_replace("%%LOWERLIMITKG%%",$lowerlimitkg,$uppertext); $uppertext=str_replace("%%UPPERLIMIT%%",$upperlimit,$uppertext); $uppertext=str_replace("%%UPPERLIMITKG%%",$upperlimitkg,$uppertext); } ?> <form method="post">
<div class="calculator_div">
<div><input type="radio" value="english" name="system" <?php if($_SESSION['bmi_calc_system']=="" or $_SESSION['bmi_calc_system']=='english') echo "checked='true'";?> onclick="changeSystem('english');"> Imperial
<input type="radio" value="metric" name="system" <?php if($_SESSION['bmi_calc_system']!='' and $_SESSION['bmi_calc_system']=='metric') echo "checked='true'";?> onclick="changeSystem('metric');"> Metric
</div>
<div><label>Your Weight:</label>
<span id="englishWeight" style="display:<?php echo ($_SESSION['bmi_calc_system']=='' or $_SESSION['bmi_calc_system']=='english')?'block':'none'?>;"><input type="text" name="weight_en" size="10" value="<?php echo !empty($_SESSION['bmi_calc_weight_en'])?$_SESSION['bmi_calc_weight_en']:""?>"> lbs</span>
<span id="metricWeight" style="display:<?php echo (($_SESSION['bmi_calc_system']=="" or $_SESSION['bmi_calc_system']=='english'))?'none':'block'?>;"><input type="text" name="weight_met" size="10" value="<?php echo !empty($_SESSION['bmi_calc_weight_met'])?$_SESSION['bmi_calc_weight_met']:""?>"> kg</span>
</div>
<div><label>Your Height:</label>
<span id="englishHeight" style="display:<?php echo (($_SESSION['bmi_calc_system']=='' or $_SESSION['bmi_calc_system']=='english'))?'block':'none'?>;"><input type="text" size="10" name="height_ft_en" value="<?php echo !empty($_SESSION['bmi_calc_height_ft_en'])?$_SESSION['bmi_calc_height_ft_en']:""?>"> ft
<input type="text" size="10" name="height_in_en" value="<?php echo ($_SESSION['bmi_calc_height_in_en']!='')?$_SESSION['bmi_calc_height_in_en']:""?>"> in</span>
<span id="metricHeight" style="display:<?php echo ($_SESSION['bmi_calc_system']=='' or $_SESSION['bmi_calc_system']=='english')?'none':'block'?>;">
<input type="text" name="height_met" size="10" value="<?php echo ($_SESSION['bmi_calc_height_met']!='')?$_SESSION['bmi_calc_height_met']:""?>"> cm
</span>
</div>
<div align="center">
<input type="hidden" name="calculator_ok" value="ok">
<input type="submit" value="Calculate Your BMI">
</form>
<?php if(!empty($_POST['calculator_ok'])):?>
<div class="calculator_table">
<p><?=$firsttext?></p>
<?php
switch($bmimsg)
{
case 'Normal':
// you can echo here if you want for normal weight people
break;
case 'Underweight':
echo $lowertext;
break;
default:
echo $uppertext;
break;
}
?>
<?php endif;?>
[/php]