adding .5 variable to drop down menu

Discussion in 'PHP' started by b0tita, Jul 7, 2008.

  1. #1
    Hi! I'm a complete n00b when it comes to PHP and I've been trying to figure this out for hours and hours and hours... Please help. I beg of you!

    //create "Select Bathrooms"
    $SelectBathrooms = "<select name=bathrooms>\n\t<option value=\"\"></option>\n\t";

    for($r = '0'; $r <= '10'; $r++)
    {
    if($ap[bathrooms] == $r)
    {
    $SelectBathrooms .= "<option value=\"$r\" selected>$r</option>\n\t";
    }
    else
    {
    $SelectBathrooms .= "<option value=\"$r\">$r</option>\n\t";
    }
    }

    $SelectBathrooms .= "</select>\n";

    I've scoured the internet in search for how to put more variables. As it is now, it shows 1-10 as stated in the function, but I need to put .5, 1.5, 2.5, etc. If there's anybody out there that can help us~ <3

    Thank you!
     
    b0tita, Jul 7, 2008 IP
  2. clarky_y2k3

    clarky_y2k3 Well-Known Member

    Messages:
    114
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    108
    #2
    You just need to increment your variable by 0.5 as opposed to 1.

    
    for($r = 0; $r <= 10.5; $r += 0.5)
    
    PHP:
     
    clarky_y2k3, Jul 7, 2008 IP
  3. b0tita

    b0tita Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <3 thank you so much! that worked perfectly.
     
    b0tita, Jul 8, 2008 IP