日期:2014-05-17  浏览次数:20398 次

php怎么处理复选的投票功能
小弟有个问题想请教大家
我现在有个复选框的表单
<form action='' method='post' name="form">
<input type="checkbox" id="sel" name="sel" value="yes" >
<br/>
<input type="checkbox" id="car" name="sport[]" value="1">篮球<br/>
<input type="checkbox" id="car" name="sport[]" value="2">足球<br/>
<input type="checkbox" id="car" name="sport[]" value="3">排球<br/>
<input type="submit" value="添加">
</form>

数据库是这样的:
id name tic(得票数)
1 篮球 0
2 足球 0
3 排球 0

我想实现的功能是表单提交后,选中的复选框对应的数据库里的tic得票数加1


------解决方案--------------------
PHP code
foreach($_POST['sport'] as $id){
         mysql_query("update tt set tic=tic+1 where id=$id");
}