SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help selecting field data through adrop down list

    I have several sets of information that need to be selected through drop down lists. I need to select the field from the list, as well as passing other fields from the same data row into unique new fields.

    I currently have the drop down selecting the correct fields, then I am attempting to add the other info through text boxes, unfortunately the text box becomes a loop that shows a text box for all 800+ entries. How can I make my text box selection equal to the same row as my drop down list?

    See what is happening here: http://pitzermedia.com/esalem/explode.php

    from my initial page:

    PHP Code:
        <?php

    $query
    ="SELECT id, PMS, HEX FROM PMStoHEX";
    $result=mysql_query($query);

    echo 
    '<select name="spot1">';
    while(
    $nt=mysql_fetch_array($result)) 
    // Array or records stored in nt
    echo '<option value="'.$nt['PMS'].'">' .$nt['PMS'].'</option>';}


    $query="SELECT id, PMS, HEX FROM PMStoHEX";
    $result=mysql_query($query);
    while(
    $nt=mysql_fetch_array($result))
    {
    echo
    '<input name="HEX1" type="text" value="'.$nt['HEX'].'"></input>'
    }
    echo 
    '</select>'// closing list
    ?>
    then from my action page:

    PHP Code:
    mysql_select_db($database_doristest$doristest);
    $part explode("|"$_POST['PMS']);
    // $part[0] is now id// $part[1] is now pms// $part[2] is now hex
    $id=$part[0];
    $pms=$part[1];
    $hex=$part[2]; 

    Thanks for any help,

    Patrick

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,810
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    Okay, on your page I see 7 drop downs. Do you want 1 text box for each drop down? And the value of the color selected in the drop down needs to be shown in the text box?

  3. #3
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    Okay, on your page I see 7 drop downs. Do you want 1 text box for each drop down? And the value of the color selected in the drop down needs to be shown in the text box?
    The seven dropdown boxes will be color name choices. The text boxes will hold the hexadecimal eqivalent to the color name. Each color name is from a row that holds the color names in one field, and the hex number in another field from the same row, same id.

    I need one textbox per dropdown.

    Thanks,
    Patrick

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,810
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    The following should give you 1 text box to each drop down, I'm still unsure how you are getting 7 drop downs though, or how to know which value to put in the text box.

    PHP Code:
    <?php
    $query
    ="SELECT id, PMS, HEX FROM PMStoHEX";
    $result=mysql_query($query);
    $hexValue '';
    echo 
    '<select name="spot1">';
    while(
    $nt=mysql_fetch_array($result)) 
    // Array or records stored in nt
    echo '<option value="'.$nt['PMS'].'">' .$nt['PMS'].'</option>';}
    if (
    strlen($hexValue) === 0)
    {
      
    $hexValue $nt['HEX'];
    }
    }
    echo 
    '</select>'// closing list
    echo'<input name="HEX1" type="text" value="'.$hexValue.'"></input>'
    ?>

  5. #5
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [QUOTE=cpradio;5169715 I'm still unsure how you are getting 7 drop downs though, or how to know which value to put in the text box.

    To get the seven drop downs, I just repeat this sequence seven times.

    The reason for my posting is to find someway to have the text box receive a value stored in the same row as the drop down data.

    My table has rows comprised of 'id', 'PMS'(pantone color name), and 'HEX'(hexadecimal equivalent of the pantone color name). The drop down selects the "PMS' name, and I want to pass the 'HEX' data from the same row. 'PMS' goes into one field in a new table, and I need the 'HEX' data to fill into the next field in the new table. I have found that I can get the "HEX data to pass into a text box, but cannot get only the single "HEX' that matches the 'PMS' row. I'm sure there is something I'm missing here because I feel that I should be able to set it up by the row 'id'.

    It is nice to have access to more minds than my own here, and appreciate the feedback and assistance.

    Patrick


Bookmarks

Posting Permissions

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