0
我有一個表(type,typeID,toID)我想創建一個結果數組並檢查/取消選中相關的複選框,我有代碼不工作它只檢查第一個複選框。從mysql結果檢查複選框
<ul class="fields">
<?php
//
$query = mysql_query("SELECT typeID FROM assign WHERE type='shades' AND toID='$row[ID]'")or die(mysql_error());
$item = mysql_fetch_array($query);
echo'
<li>
<label>
<input type="checkbox" class="checkbox" name="shades[]" ';
if(in_array("2",$item)){
echo" checked=\"checked\" ";};
echo'value="2"/>Front Shade</label>
</li>
<li>
<label><input type="checkbox" class="checkbox" name="shades[]" ';
if(in_array("4",$item)){echo" checked=\"checked\" ";};
echo'value="4"/>1 Pair of End Shades</label>
<li>
<label><input type="checkbox" class="checkbox" name="shades[]" ';
if(in_array("1",$item)){echo" checked=\"checked\" ";};
echo'value="1"/>Left End Shade</label>
</li>
<li>
<label><input type="checkbox" class="checkbox" name="shades[]" ';
if(in_array("3",$item)){echo" checked=\"checked\" ";};
echo'value="3"/>Right End Shade</label>
</li>
';
?>
</ul>