Home > Backend Development > PHP Tutorial > php如何同时批量传二个值zf_id和id执行mysql数据累加和插入

php如何同时批量传二个值zf_id和id执行mysql数据累加和插入

WBOY
Release: 2016-06-13 11:56:52
Original
1210 people have browsed it

php怎么同时批量传二个值zf_id和id执行mysql数据累加和插入?
1.php

<br /><form action="2.php" method="POST"><br /><br /><?<br />$query7="select * from member";<br />$result7=$obj_db->simplequery($query7);<br />while ($arr7=$obj_db->fetchrow($result7,DB_FETCHMODE_ASSOC))<br />{<br />$i++;<br /><br />echo "实到<input type=\"radio\" name=\"zf_id[]\" value=\"1\" />, 未到<input type=\"radio\" name=\"zf_id[]\" value=\"2\" />, 请假<input type=\"radio\" name=\"zf_id[]\" value=\"3\" /><input type=\"hidden\" name=\"id[]\" value=\"$arr7[id]\">";//zf_id批量输出后单选值=1或2或3,怎么能实现每行一个单选?这样输出只能一个页面一个单选<br /><br /><br />}<br />?><br /><br /><input type="submit" name="B2" value="提交" /><input type="hidden" name="ftsy" value="1"></form>
Copy after login




2.php:
if($ftsy=="1"){<br />  $zf_num=count($id); <br />  echo "批量处理 $zf_num 条记录<br>";<br />  for($i=0;$i<$zf_num;$i++){ <br /><br /><br />if($zf_id[$i]=="1"){<br /> $obj_db->simplequery("update member set yzfwyx=yzfwyx+1 where id='$id[$i]'");//<br />$query28="insert into kaohe (kh_mid,kh_id,khyx,khtime) values ('$id[$i]','$xiuid','1','$srtime')";<br />$obj_db->simplequery($query28);<br /><br />}<br /><br />if($zf_id[$i]=="2"){<br /> $obj_db->simplequery("update member set yzfwwx=yzfwwx+1 where id='$id[$i]'");//<br />$query28="insert into kaohe (kh_mid,kh_id,khwx,khtime) values ('$id[$i]','$xiuid','1','$srtime')";<br />$obj_db->simplequery($query28);<br />}<br /><br />if($zf_id[$i]=="3"){<br /> $obj_db->simplequery("update member set yzfwqj=yzfwqj+1 where id='$id[$i]'");//<br />$query28="insert into kaohe (kh_mid,kh_id,khqj,khtime) values ('$id[$i]','$xiuid','1','$srtime')";<br />$obj_db->simplequery($query28);<br />}<br /><br /><br />  echo "<br>处理ID: $id[$i]"; <br />}<br />exit();<br />   } 
Copy after login

请高手帮写出详细代码,谢谢!

------解决方案--------------------
\"zf_id[]\" 写作 \"zf_id[$i]\"

为保证唯一定位,因为你将做 update
应写作 \"zf_id[$arr7[id]]\"

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template