0

下面是我的带有值的静态复选框。

我需要的是当用户检查任何复选框然后单击提交时我需要在 php 中进一步检查检查 kboxes 值我想将它们放在 mysql 查询中,如下所示

select * from table where "all check boxes values"

我在 mysql 中的搜索将基于所有检查的值

echo "<table border='0'>";
echo "<p>Make a Selection to view details</p>";
echo "<tr><th>Scheme Type</th><th>Scehme Sector</th><th>Area</th><th>Year</th></tr>";
echo "<tr><td><input type='checkbox' name='chkSkills' value='ADP' /> District ADP <br/>";
echo "<input type='checkbox' name='chkSkills' value='cmd'/> CM Directives <br/>";
echo "<input type='checkbox' name='chkSkills' value='tkpp'/> Tameer KPK Program <br/>";
echo "<input type='checkbox' name='chkSkills' value='tbcess' /> Tobacco Cess</td>";
echo "<td><input type='checkbox' name='chkSkills' value='wss' /> Water Supply & Sanitation <br/>";
echo "<input type='checkbox' name='chkSkills' value='road'/> Roads <br/>";
    echo "<input type='checkbox' name='chkSkills' value='ccb'/> CCB <br/>";
echo "<input type='checkbox' name='chkSkills' value='health'/> Health <br/>";
echo "<input type='checkbox' name='chkSkills' value='education'/> Education <br/>";
echo "<input type='checkbox' name='chkSkills' value='others' /> Others</td>";
echo "<td><input type='checkbox' name='chkSkills' value='pk77'/> PK-77 <br/>";
echo "<input type='checkbox' name='chkSkills' value='pk78'/> PK-78 <br/>";
echo "<input type='checkbox' name='chkSkills' value='pk79' /> PK-79 </td>";
echo "<td><input type='checkbox' name='chkSkills' value='1112'/> 2011-12 <br/>";
echo "<input type='checkbox' name='chkSkills' value='1011'/> 2010-11 </td></tr>";
echo  "<tr><td colspan='4' align='right' style='background-color:white;'><input type='submit' name='devsub' value='Submit' /></td></tr>";
echo "</table>";

问候

4

2 回答 2

1

更改name = chkSkills[]每个复选框并通过检索$_POST['chkSkills']

不仅仅是这样做

foreach($_POST['chkSkills'] as $key => $value){
MYSQL_QUERY
}
于 2012-04-13T06:09:22.700 回答
0

使用名称 chkSkills[] 然后

在php中使用

if(count($_POST['chkSkills']) > 0)
{
     $checkboxes=implode(',',$_POST['chkSkills']);
}

然后进行查询

select * from table where cloumnname in($checkboxes)

于 2012-04-13T06:18:31.047 回答