]; 2 , the backend accepts such as [$id = $_POST [id] [$i]]."/> ]; 2 , the backend accepts such as [$id = $_POST [id] [$i]].">
Home >Backend Development >PHP Problem >How to batch POST modification in php
How to modify php batch POST: 1. Add [[]] to the name in the front-end form, and the code is [bbe61de236c63370b05e2b2749c5cb86<input type="hidden" name="id[]" value="{$vo.id}">]; 2. The backend accepts [$id = $_POST [id] [$i]].
How to modify php batch POST:
Add []## to the name in the front-end form #, such as:
<input type="hidden" name="id[]" value="{$vo.id}">The backend accepts such as: $id = $_POST [id] [$i]; $i is the loop variable in for. When $i is the same, $_POST [id] can be made [$i] and $_POST [name] [$i] are in one-to-one correspondence; [Related learning recommendations:
php programming (video)]
Front-end form:
Server-side processing:
/** * 批量修改状态 */ public function updateList() { $result = false; for($i = 0; $i < count ( $_POST [id] ); $i ++) { $id = $_POST [id] [$i]; $check = $_POST [check] [$i]; $status = $_POST [status] [$i]; // 保存登录信息 $Repair = M ( 'Repair' ); $data ['id'] = $id; $data ['check'] = $check; $data ['status'] = $status; $result = $Repair->save ( $data ); } if (false !== $result) { $this->success ( '修改成功!' ); } else { $this->error ( '修改失败!' ); } }[Related learning recommendations:
Programming video]
The above is the detailed content of How to batch POST modification in php. For more information, please follow other related articles on the PHP Chinese website!