php批量修改有关问题

WBOY
Release: 2016-06-13 11:49:52
Original
794 people have browsed it

php批量修改问题
表 user 
user_id  money
 1        1000
 2        1500
 3        1200
 4        1300

如何批量修改money字段?
前端代码:
 
 
 

问:如何处理$_POST['user']和$_POST['jf']两个数组,并保证两个值是一一对应的?
具体的代码如何写?先谢谢大家!
------解决方案--------------------
没有被选中的 checkbox 不会被提交
checkbox 提交的是值(数组)

按你的设计
$_POST['jf'][$_POST['user'][i]-1] 就是 user 对应的 jf
i 为传入的 $_POST['user'] 数组的下标

通常宜这样做
 
 
使得一开始就一一对应
------解决方案--------------------

 
 


<br />$jf 	= $_POST['jf'];<br />$user 	= $_POST['user'];<br />foreach($user as $v){<br />	echo $jf[$v];<br />}<br />
Copy after login

------解决方案--------------------


foreach($_POST['user'] as $k) {<br />  printf('%s %s', $k, $_POST['jf'][$k-1]);<br />}
Copy after login



foreach($_POST['user'] as $k) {<br />  printf('%s %s', $k, $_POST['jf'][$k]);<br />}
Copy after login

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