In my edit user form I have multiple select area. In here i wanna show currently assigned laboratories for users and also provide access to edit them. This is how i have done it.
<?php
$result1 = mysql_query("Select *
from members
JOIN lab_employee on members.emp_id = lab_employee.emp_id
JOIN lab on lab_employee.lab_id = lab.lab_id
where members.emp_id=$emp_id")
or die(mysql_error());
$query="SELECT * FROM lab";
$dropdown = "<select name='labid[]' multiple='multiple' style='height:80px;' size='5'>";
//$dropdown .= "<option value=''>Select lab to assign </option>";
$result2 = mysql_query ($query);
while($row2 = mysql_fetch_assoc($result2))
{
$dropdown .= "\r\n<option value='{$row2['lab_id']}'";
while($row1 = mysql_fetch_assoc($result1))
{
if(($row1['lab_id'])==($row2['lab_id']))
{
$dropdown .=" selected='selected'";
}
}
$dropdown .= ">{$row2['l_name']}</option>";
}
$dropdown .= "\r\n</select>";
echo $dropdown;
?>
But the problem is if there are multiple selections only 1st selection is shown. If there is only 1 selection then its ok. Need ur help to find the error