Heim > Backend-Entwicklung > PHP-Tutorial > php批量POST修改_PHP教程

php批量POST修改_PHP教程

WBOY
Freigeben: 2016-07-20 11:16:18
Original
945 Leute haben es durchsucht

这是一个thinkphp中的批量修改的案例:

 如需要删除多项,或者同时修改多项记录

前端表单:

<span <</span><span form </span><span name</span><span ="form1"</span><span  method</span><span ="post"</span><span  action</span><span ="__GROUP__/Repair/updateList"</span><span ></span><span 
  对所选操作:</span><span <</span><span input </span><span type</span><span ="submit"</span><span  value</span><span ="保 存"</span><span  class</span><span ="btn btn-primary"</span><span ></span> <span <</span><span br</span><span ></span>
            <span <</span><span table </span><span id</span><span ="checkList"</span><span  class</span><span ="list table table-hover"</span><span ></span>
                <span <</span><span tr</span><span ></span>
                    <span <</span><span th </span><span scope</span><span ="col"</span><span ><</span><span input </span><span id</span><span ="check"</span><span  type</span><span ="checkbox"</span><span 
                        onclick</span><span ="checkAll()"</span> <span /></span> 全选<span </</span><span th</span><span ></span>
                    <span <</span><span th </span><span scope</span><span ="col"</span><span ></span>主题<span </</span><span th</span><span ></span>
                    <span <</span><span th </span><span scope</span><span ="col"</span><span ></span>校区<span </</span><span th</span><span ></span>
                    <span <</span><span th </span><span scope</span><span ="col"</span><span ></span>房间<span </</span><span th</span><span ></span>
                    <span <</span><span th </span><span scope</span><span ="col"</span><span ></span>报修人<span </</span><span th</span><span ></span>
                    <span <</span><span th </span><span scope</span><span ="col"</span><span ></span>联系电话<span </</span><span th</span><span ></span>
                    <span <</span><span th </span><span scope</span><span ="col"</span><span ></span>报修时间<span </</span><span th</span><span ></span>
                    <span <</span><span th </span><span scope</span><span ="col"</span><span ></span>审核<span </</span><span th</span><span ></span>
                    <span <</span><span th </span><span scope</span><span ="col"</span><span ></span>报修状态<span </</span><span th</span><span ></span>
                <span </</span><span tr</span><span ></span>
                <span <</span><span volist </span><span name</span><span ="list"</span><span  id</span><span ="vo"</span><span ></span>
                <span <</span><span tr</span><span ></span>
                    <span <</span><span td</span><span ><</span><span input </span><span type</span><span ="checkbox"</span><span  name</span><span ="key"</span><span  value</span><span ="{$vo.id}"</span><span ></span>{$vo.id}<span <</span><span input </span><span type</span><span ="hidden"</span><span  name</span><span ="id[]"</span><span  value</span><span ="{$vo.id}"</span><span ></</span><span td</span><span ></span>
                    <span <</span><span td</span><span ></span>{$vo.topic}<span </</span><span td</span><span ></span>
                    <span <</span><span td</span><span ></span>{$vo.xiaoqu}<span </</span><span td</span><span ></span>
                    <span <</span><span td</span><span ></span>{$vo.room}<span </</span><span td</span><span ></span>
                    <span <</span><span td</span><span ></span>{$vo.pname}<span </</span><span td</span><span ></span>
                    <span <</span><span td</span><span ></span>{$vo.phone}<span </</span><span td</span><span ></span>
                    <span <</span><span td</span><span ></span>{$vo.create_time|date='Y-m-d H:i:s',###}<span </</span><span td</span><span ></span>
                    <span <</span><span td</span><span ><</span><span select </span><span name</span><span ="check[]"</span><span ><</span><span switch </span><span name</span><span ="vo.check"</span><span ></span>
                            <span <</span><span case </span><span value</span><span ="0"</span><span ></span>
                            <span <</span><span option </span><span value</span><span ="0"</span><span  selected</span><span ="selected"</span><span ></span>未审核<span </</span><span option</span><span ></span>
                            <span <</span><span option </span><span value</span><span ="1"</span><span ></span>审核<span </</span><span option</span><span ></span>
                            <span </</span><span case</span><span ></span> <span <</span><span default </span><span /></span>
                            <span <</span><span option </span><span value</span><span ="0"</span><span ></span>未审核<span </</span><span option</span><span ></span>
                            <span <</span><span option </span><span value</span><span ="1"</span><span  selected</span><span ="selected"</span><span ></span>审核<span </</span><span option</span><span ></span>
                            <span </</span><span switch</span><span ></</span><span select</span><span ></</span><span td</span><span ></span>
                    <span <</span><span td</span><span ><</span><span select </span><span name</span><span ="status[]"</span><span ><</span><span switch </span><span name</span><span ="vo.status"</span><span ></span>
                            <span <</span><span case </span><span value</span><span ="已修"</span><span ></span>
                            <span <</span><span option </span><span value</span><span ="未修"</span><span ></span>未修<span </</span><span option</span><span ></span>
                            <span <</span><span option </span><span value</span><span ="任务已下"</span><span ></span>任务已下<span </</span><span option</span><span ></span>
                            <span <</span><span option </span><span value</span><span ="已修"</span><span  selected</span><span ="selected"</span><span ></span>已修<span </</span><span option</span><span ></span>
                            <span </</span><span case</span><span ></span> <span <</span><span case </span><span value</span><span ="任务已下"</span><span ></span>
                            <span <</span><span option </span><span value</span><span ="未修"</span><span ></span>未修<span </</span><span option</span><span ></span>
                            <span <</span><span option </span><span value</span><span ="任务已下"</span><span  selected</span><span ="selected"</span><span ></span>任务已下<span </</span><span option</span><span ></span>
                            <span <</span><span option </span><span value</span><span ="已修"</span><span ></span>已修<span </</span><span option</span><span ></span>
                            <span </</span><span case</span><span ></span> <span <</span><span default </span><span /></span>
                            <span <</span><span option </span><span value</span><span ="未修"</span><span  selected</span><span ="selected"</span><span ></span>未修<span </</span><span option</span><span ></span>
                            <span <</span><span option </span><span value</span><span ="任务已下"</span><span ></span>任务已下<span </</span><span option</span><span ></span>
                            <span <</span><span option </span><span value</span><span ="已修"</span><span ></span>已修<span </</span><span option</span><span ></span>
                            <span </</span><span switch</span><span ></</span><span select</span><span ></</span><span td</span><span ></span>
                <span </</span><span tr</span><span ></span>
                <span </</span><span volist</span><span ></span>
            <span </</span><span table</span><span ></span>
        <span </</span><span form</span><span ></span>
Nach dem Login kopieren

服务端处理:

    <span /*</span><span *
     * 批量修改状态
     </span><span */</span>
    <span public</span> <span function</span><span  updateList() {
        </span><span $result</span> = <span false</span><span ;
        </span><span for</span>(<span $i</span> = 0; <span $i</span> < <span count</span> ( <span $_POST</span> [id] ); <span $i</span> ++<span ) {
            
            </span><span $id</span> = <span $_POST</span> [id] [<span $i</span><span ];
            </span><span $check</span> = <span $_POST</span> [check] [<span $i</span><span ];
            </span><span $status</span> = <span $_POST</span> [status] [<span $i</span><span ];
            
            </span><span //</span><span  保存登录信息</span>
            <span $Repair</span> = M ( 'Repair'<span  );
            </span><span $data</span> ['id'] = <span $id</span><span ;
            </span><span $data</span> ['check'] = <span $check</span><span ;
            </span><span $data</span> ['status'] = <span $status</span><span ;
            </span><span $result</span> = <span $Repair</span>->save ( <span $data</span><span  );
        }
        
        </span><span if</span> (<span false</span> !== <span $result</span><span ) {
            </span><span $this</span>->success ( '修改成功!'<span  );
        } </span><span else</span><span  {
            </span><span $this</span>->error ( '修改失败!'<span  );
        }
    }        </span>
Nach dem Login kopieren

 

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/440117.htmlTechArticle这是一个thinkphp中的批量修改的案例: 如需要删除多项,或者同时修改多项记录 前端表单: 全选 主题 校区 房间 报修人 联系电话 报修时...
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage