Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lahore, Pakistan
    Posts
    150
    Thanks
    2
    Thanked 0 Times in 0 Posts

    storing values in combo box

    HI,
    in database there is a one record stored that is

    M-L-XL-XXL

    i want to retrieve this record from database and show it in combo box. MEans i want four values in combobox which are
    M
    L
    XL
    XXL


    how can i seperate each value and implement it

    plz reply
    eshban

  • #2
    New Coder
    Join Date
    Jul 2005
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts
    After retrieve values in proper order you put this code:
    <select name="name">
    <option>Choose One</option>
    <?for($i=0;$i<$br;$i++){?>
    <option value="<?=$res[0]"><?echo $res[0];?></option>
    <?}?>
    </select>

    where $br is count of fields in your table;
    $res[] is result from retrieving data from table
    If you can not find a decision, maybe you have to try to change a problem

    http://www.gunman.co.nr
    http://bglinux.org

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    And with that you end up with $br options for the exact same thing.
    I'm assuming that you know how to query here, and we will store the value result of 'M-L-XL-XXL' in variable $row:
    PHP Code:
    /* $row = 'M-L-XL-XXL'; */
    $row explode('-'$row);
    // Now we have an array:
    if (!empty($row))
    {
         echo 
    '<select name="selectname">';
         for (
    $i 0$i count($row); $i++)
         {
              echo 
    '<option value="' $row[$i] . '">' $row[$i] . '</option>';
         }
         echo 
    '</select>';

    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •