GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Webmaster Q & Fuckin' A (https://gfy.com/forumdisplay.php?f=27)
-   -   coding question (https://gfy.com/showthread.php?t=1131306)

Ketchup 01-17-2014 02:02 PM

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>

sarettah 01-17-2014 03:21 PM

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>

Ketchup 01-17-2014 04:14 PM

Quote:

Originally Posted by sarettah (Post 19948463)
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.

thanks for your help yes that is what I am trying to do is make it display in feet in the profile page

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>

sarettah 01-17-2014 04:41 PM

Quote:

Originally Posted by Ketchup (Post 19948525)
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!

Same as we did the select, just divide height by 12 (12 inches in a foot) and then get the remainder for the left over inches:

intval($height/12) . ' feet ' . ($height-(intval($height/12)*12)) . ' inches';

sarettah 01-17-2014 05:13 PM

Quote:

Originally Posted by sarettah (Post 19948548)
Same as we did the select, just divide height by 12 (12 inches in a foot) and then get the remainder for the left over inches:

intval($height/12) . ' feet ' . ($height-(intval($height/12)*12)) . ' inches';

Actually that should be:

<?=intval($detail['height']/12) . ' feet ' . ($detail['height']-(intval($detail['height']/12)*12)) . ' inches';?>

Where you have:

<?=$detail['height'];?>

Hate when I screw up :(

Ketchup 01-17-2014 05:45 PM

it works!

Thanks very much you rock! :banana

sarettah 01-19-2014 11:59 AM

Quote:

Originally Posted by Ketchup (Post 19948602)
it works!

You sound surprised?


Quote:

Thanks very much you rock! :banana
np


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