thanks, LordShryku
I tried out your solutions as is - and all I got was the same value repeated 'count' times. I tried inserting the line
$id=$pieces(i); but although I could get the correct selected values, I was not getting all the possible values form the field.
$pieces = explode(" ", $product_id);
echo "<select multiple name=\"product_id\">";
for($i=0;$i<count($pieces);$i++) {
$id=$pieces[$i];
$query = "SELECT product_name
FROM product
WHERE product_id='".$id."'";
$xresult = mysql_query($query);
$product_name=mysql_result($xresult,0);
echo "<option value=\"".$product_name."\" selected>".$product_name;
}
Here's the scenario: suppose I have values a, b, c, d in a multi select list box list (with corresponding id#'s 1, 2, 3, 4). Although a, b, c and d are displayed, there are retrieved from parent table z; table x only stores the id's (concatenated, as I previously pointed out.
b an c are selected and the form is submitted, values 2 and 3 are duly inserted into field x1 in table x as a string "2 3". When the string retrieved, I first split into the original id's 2 and 3; and then I retrieve the respective display values b nd c from the parent table - and display them in a list box as selected... I have been able to succesful do this with your help...
But what I eventually want to have is the resulting list box display all the values (a,b,c and d) and showing b and c selected (highlighted). Can you please help me ou with this part?
$id=$pieces($i);