Php batch modification problem table & nbsp; user & nbsp; user_id & nbsp; money & nbsp; 1 & nbsp; & nbsp; 1000 & nbsp; 2 & nbsp; php batch modification problems
Table user
User_id money
1 1000
2 1500
3 1200
4 1300
How to modify the money field in batches?
Front-end code:
Q: How to deal with the $ _ POST ['user'] and $ _ POST ['jf'] Arrays and ensure that the two values correspond one to one?
How to write specific code? Thank you!
------ Solution --------------------
Unselected checkbox is not submitted
Checkbox submits values (arrays)
According to your design
$ _ POST ['jf'] [$ _ POST ['user'] [I]-1] is the jf
I is the subscript of the passed $ _ POST ['user'] array.
This is usually recommended
Make one-to-one correspondence at the beginning
------ Solution --------------------
$jf = $_POST['jf'];
$user = $_POST['user'];
foreach($user as $v){
echo $jf[$v];
}
------ Solution --------------------
Hour
foreach($_POST['user'] as $k) {
printf('%s %s', $k, $_POST['jf'][$k-1]);
}
Hour
foreach($_POST['user'] as $k) {
printf('%s %s', $k, $_POST['jf'][$k]);
}