Php 从数据库中选择内爆值并在下拉框中选择它们

Php 从数据库中选择内爆值并在下拉框中选择它们,php,Php,我有下面的代码来生成一个多选择框,其中包含来自数据库的值。该页面是用于修改以前输入的信息的表单。在生成框之前检索“$S0”的值。如果“$Conceducers0”的值为“John Doe”,则选择该名称即可。但如果我的值为“John Doe,Jane Doe”,则不会选择任何名称。我知道这是因为内爆的价值,但我还没有弄清楚。提前谢谢 { $box1 = array(); $result = "SELECT FullName FROM UserInformation"; $rs=odbc_e

我有下面的代码来生成一个多选择框,其中包含来自数据库的值。该页面是用于修改以前输入的信息的表单。在生成框之前检索“$S0”的值。如果“$Conceducers0”的值为“John Doe”,则选择该名称即可。但如果我的值为“John Doe,Jane Doe”,则不会选择任何名称。我知道这是因为内爆的价值,但我还没有弄清楚。提前谢谢

{
$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;
{
$box1=数组();
$result=“从用户信息中选择全名”;
$rs=odbc_exec($conn,$result);
而($row=odbc_fetch_数组($rs)){$box1[]=$row;}
}
$面试官='';
$Occessors.='-<选择面试官>-';
如果(!empty($box1)){foreach($box1作为$k=>$v)
{if(!empty($octavers0)){$octavers.=''.$v['FullName'].';}
其他的
{$Occessors.=''.$v['FullName'.].';}
}
}
$采访者='';
采访者;

您要查找的内容可以通过以下方式完成:

因此,请使用:

(strpos($v['FullName'], $Interviewers0) !== false) ? ' selected' : ''
而不是:

!strcmp($v['FullName'],$Interviewers0)?' selected':''
使用
(strpos($v['FullName',$conversators0)!==false)?”所选“:”
,如果在
$v['FullName']
中找到
$conversts0
,则选择
选项。

I

(!strcmp($v['FullName'],$Interviewers0)?' selected':'')


就是这样。

我在您的代码中没有看到任何
内爆()
。请学会正确缩进代码,不要害怕使用空格。没有人会因为你这样做而认为你是种族主义者。
((stripos($Interviewers0, $v['FullName']) !== false) ?' selected':'')