coding question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ketchup
    Confirmed User
    • Jul 2006
    • 563

    #1

    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>
    https://www.instagram.com/tsrocketqueen/

    https://torontoshemaleescorts.com
  • sarettah
    see you later, I'm gone
    • Oct 2002
    • 14293

    #2
    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>
    Last edited by sarettah; 01-17-2014, 01:27 PM.
    All cookies cleared!

    Comment

    • Ketchup
      Confirmed User
      • Jul 2006
      • 563

      #3
      Originally posted by sarettah
      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>
      Last edited by Ketchup; 01-17-2014, 02:23 PM.
      https://www.instagram.com/tsrocketqueen/

      https://torontoshemaleescorts.com

      Comment

      • sarettah
        see you later, I'm gone
        • Oct 2002
        • 14293

        #4
        Originally posted by Ketchup
        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';
        All cookies cleared!

        Comment

        • sarettah
          see you later, I'm gone
          • Oct 2002
          • 14293

          #5
          Originally posted by sarettah
          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
          All cookies cleared!

          Comment

          • Ketchup
            Confirmed User
            • Jul 2006
            • 563

            #6
            it works!

            Thanks very much you rock!
            https://www.instagram.com/tsrocketqueen/

            https://torontoshemaleescorts.com

            Comment

            • sarettah
              see you later, I'm gone
              • Oct 2002
              • 14293

              #7
              Originally posted by Ketchup
              it works!
              You sound surprised?


              Thanks very much you rock!
              np
              All cookies cleared!

              Comment

              Working...