I have the below code to generate a multiple select box with values from a database. The page in question is a form for modifying previously entered information. The value of “$Interviewers0” is retrieve before the box is generated. If the value of “$Interviewers0” is “John Doe” it selects that name fine. But if I have a value of “John Doe, Jane Doe” none of the names are selected. I know it’s because of the imploded value but I haven’t been able to figure it out. Thanks in advance!
{
$box1 = array();
$result = "SELECT FullName FROM UserInformation";
$rs=odbc_exec($conn,$result);
while($row = odbc_fetch_array($rs)) { $box1[] = $row; }
}
$Interviewers = '<select name="Interviewers[]" multiple="multiple" size="5">';
$Interviewers .= '<option>---< Select Interviewers >---</option>';
if (!empty($box1)) {foreach ($box1 as $k => $v)
{if(!empty($Interviewers0)){$Interviewers .= '<option value="'.$v['FullName'].'"'. (!strcmp($v['FullName'],$Interviewers0)?' selected':'').'>'.$v['FullName'].'</option>';}
else
{$Interviewers .= '<option value="'.$v['FullName'].'">'.$v['FullName'].'</option>';}
}
}
$Interviewers .= '</select>';
echo $Interviewers;
implode()
in your code... – Justin Wood