下面是带有值的静态复选框。
我需要的是当用户检查任何复选框然后单击提交我需要在php中检查chec 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>";
此致
答案 0 :(得分:1)
为每个复选框更改name = chkSkills[]
并通过$_POST['chkSkills']
不仅仅是这样做
foreach($_POST['chkSkills'] as $key => $value){
MYSQL_QUERY
}
答案 1 :(得分:0)
使用名称chkSkills []然后
在php中使用
if(count($_POST['chkSkills']) > 0)
{
$checkboxes=implode(',',$_POST['chkSkills']);
}
然后 进行查询
从($ checkboxes)
中的cloumnname表中选择*