我試圖檢索選中的複選框,其值存儲在數據庫中,但他們總是,即使他們在數據庫中存在未經檢查。 我都試過,但沒有奏效,儘管不同的結構相同的代碼工作,但對於框架的原因,我需要以此來實現:複選框沒有得到遏制
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>";
所以,當你做'in_array($ compi ['Competence_ID'],$ tmp)){'...你可以退出($ checked);'看看它是否在那裏設置?如果沒有...幾乎知道你的問題在哪裏.. – Ohgodwhy 2013-03-20 08:18:09
嘗試在'checked'關鍵字周圍放置空格 – 2013-03-20 08:19:47
謝謝Gareth!工作! – auicsc 2013-03-20 08:28:00