]; 2 , the backend accepts such as [$id = $_POST [id] [$i]]."/> ]; 2 , the backend accepts such as [$id = $_POST [id] [$i]].">

Home  >  Article  >  Backend Development  >  How to batch POST modification in php

How to batch POST modification in php

coldplay.xixi
coldplay.xixiOriginal
2020-08-15 15:32:063204browse

How to modify php batch POST: 1. Add [[]] to the name in the front-end form, and the code is [bbe61de236c63370b05e2b2749c5cb86]; 2. The backend accepts [$id = $_POST [id] [$i]].

How to batch POST modification in php

How to modify php batch POST:

Add []## to the name in the front-end form #, such as:

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:

对所选操作:
全选 主题 校区 房间 报修人 联系电话 报修时间 审核 报修状态
{$vo.id} {$vo.topic} {$vo.xiaoqu} {$vo.room} {$vo.pname} {$vo.phone} {$vo.create_time|date='Y-m-d H:i:s',###}

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!

Statement:
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