![]() |
coding question
on a form this code is for height in inches how can i make it to display in feet ,thanks
<label>Height:</label> <select name="height" class="search_input"> <option value="">--select--</option> <? for($i=58;$i<=73;$i++) { ?> <option value="<?=$i;?>" <? if($rs['height']==$i) { echo "selected"; }?>> <?=$i;?> </option> <? } ?> </select> |
Easy enough to make it display height as feet in the select box. However, unless you are going to change the program that is handling the form to handle it as feet , you want to keep what is passed into the program as inches still.
<label>Height:</label> <select name="height" class="search_input"> <option value="">--select--</option> <? for($i=58;$i<=73;$i++) { ?> <option value="<?=$i;?>" <? if($rs['height']==$i) { echo "selected"; }?>> // to show value as feet - decimal. ie: 126 inches displayed as 10.50 <?=number_format($i/12,2);?> // to show as feet and inches ie: 126 inches = 10 feet 6 inches <?=intval($i/12) . ' feet ' . ($i-(intval($i/12)*12)) . ' inches';?> </option> <? } ?> </select> |
Quote:
the code for the people to add their profile to the site is <label>Height:</label> <select name="height" class="search_input"> <option value="">--select--</option> <? for($i=58;$i<=73;$i++) { ?> <option value="<?=$i;?>" <? if($rs['height']==$i) { echo "selected"; }?>> <?=$i;?> </option> <? } ?> </select> and the code on the actual profile page visible to public is <p>Height: <?=$detail['height'];?> how do i make that ^ display as feet? Thanks! edit it used your code as this on the create profile page and it changed it to feet now to get the profile to display in feet thanks! <label>Height:</label> <select name="height" class="search_input"> <option value="">--select--</option> <? for($i=58;$i<=73;$i++) { ?> <option value="<?=$i;?>" <? if($rs['height']==$i) { echo "selected"; }?>> <?=intval($i/12) . ' feet ' . ($i-(intval($i/12)*12)) . ' inches';?> </option> |
Quote:
intval($height/12) . ' feet ' . ($height-(intval($height/12)*12)) . ' inches'; |
Quote:
<?=intval($detail['height']/12) . ' feet ' . ($detail['height']-(intval($detail['height']/12)*12)) . ' inches';?> Where you have: <?=$detail['height'];?> Hate when I screw up :( |
it works!
Thanks very much you rock! :banana |
Quote:
Quote:
|
All times are GMT -7. The time now is 03:22 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc