refiking Posted December 13, 2008 Share Posted December 13, 2008 The height is stored in db as inches only. How can I display in feet and inches? while ($row = mysql_fetch_assoc($sql)){ $height = $row['height']; Echo $height . "<br>"; } Link to comment https://forums.phpfreaks.com/topic/136781-solved-how-to-format-height/ Share on other sites More sharing options...
Michdd Posted December 13, 2008 Share Posted December 13, 2008 Do you like if it's bigger than 11 inches then display it in terms of inches and feet? Or do you mean show it like: Inches: 24 Feet: 2 showing both. Link to comment https://forums.phpfreaks.com/topic/136781-solved-how-to-format-height/#findComment-714371 Share on other sites More sharing options...
refiking Posted December 13, 2008 Author Share Posted December 13, 2008 I'd like the output to be this: //5'11" //6'2" //7'0" Link to comment https://forums.phpfreaks.com/topic/136781-solved-how-to-format-height/#findComment-714373 Share on other sites More sharing options...
gevans Posted December 13, 2008 Share Posted December 13, 2008 imagine 5'11" $height = 71; $feet = floor($height/12); $inches = $height%12; if($feet) echo $feet."'"; if($inches) echo $inches.'"'; Link to comment https://forums.phpfreaks.com/topic/136781-solved-how-to-format-height/#findComment-714376 Share on other sites More sharing options...
justinh Posted December 13, 2008 Share Posted December 13, 2008 <?php function checkheight($height){ $feet = $height/12 % 10; $inches = $height - $feet*12; $height = $feet."'".$inches; return $height; } while($row = mysql_fetch_assoc($sql)){ $height = $row['height']; } echo checkheight($height); ?> Link to comment https://forums.phpfreaks.com/topic/136781-solved-how-to-format-height/#findComment-714378 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.