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

$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:

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

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

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
$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>';
?>

[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