我正在尝试检索其值存储在数据库中的选中复选框,但即使它们存在于数据库中,它们也始终未选中。我已经尝试过了,但它不起作用,虽然具有不同结构的相同代码可以工作,但出于框架原因,我需要使用它来实现:
if(isset($sp['Etunimi'])&&isset($sp['Sukunimi'])){
echo "<form method='post' action=''>";
$comp=$this->All_Competences;
echo"<br/>select competences for:".$sp['Etunimi'];
$id=$sp['Id'];
$tmp=array();
if(isset($_POST['select_employee'])){
$cid=$this->cids;
}
foreach($cid as $test)
{
array_push($tmp, $test['c_ID']);
}
for($i=0;$i<count($tmp);$i++){
}
echo "<table><th>valid?</th><th>Competence description</th>";
foreach($comp as $compi){
$checked='';
if(in_array($compi['Competence_ID'],$tmp)){
$checked='checked';
}
echo "<tr><td><input type='checkbox'".$checked."name='c[]' value='".$compi['Competence_ID']."'></td><td>".$compi['Competence_Description']."</td></tr>";
}
echo "</table>";
echo "<input type='hidden' name='action' value='selectchecked'>";
echo "<input type='hidden' name='id' value='".$id."'>";
echo "<input type='submit' value='submit checks'>";
echo "</form>";