我创建了一个复选框表。这些行按类别划分,选中或未选中的复选框显示在部门列下。我有很多代码,所以我将分解我提供的内容。我正在通过每一列创建一个数组(奇怪的方法,是的)。我注意到如果所有复选框都被取消选中,它会在每次循环时返回隐藏值 0。太好了,这就是我想要的。但是,如果选中了该框,它会返回值 0 和值 3。例如:
测试 = 数组()
测试[0] => 0 测试[1] => 3
如何防止它发布隐藏值?
$row_two = mysql_query("SELECT dept_id FROM categories WHERE cat_name = '{$cats['cat_name']}' and bus_id = '{$busUnits['bus_id']}'");
while (($test_two=mysql_fetch_assoc($row_two)))
{
$AnotherTest = implode(',', $test_two);
$WhatTest = explode(",", $AnotherTest);
if(in_array("3",$WhatTest, TRUE))
{
echo '<input type="hidden" name="Cat_CBC_Test_One[]" value="0">';
echo '<td><input type="checkbox" name="Cat_CBC_Test_One[]" value="3" checked></td>';
}
else
{
echo '<input type="hidden" name="Cat_CBC_Test_One[]" value="0">';
echo '<td><input type="checkbox" name="Cat_CBC_Test_One[]" value="3"></td>';
}