Blogger Information
Blog 25
fans 0
comment 0
visits 29655
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
ThinkPHP实现排序功能
宿州市筋斗云信息科技-Vip
Original
3625 people have browsed it
<!--html-->
<form action="{:url('cate/csort')}" method="post">
<div class="layui-collapse" lay-filter="test">
    <button type="submit" class="layui-btn layui-btn-xs">更新排序</button>
    <table class="layui-table" lay-size="sm">
        <thead>
        <tr>
            <th style="text-align: center;" width="5%">id</th>
            <th style="text-align: center;" width="5%">排序</th>
            <th style="text-align: center;">名称</th>
            <th style="text-align: center;" width="10%">图片</th>
            <th style="text-align: center;" width="10%">类型</th>
            <th style="text-align: center;" width="10%">模型</th>
            <th style="text-align: center;" width="10%">状态</th>
            <th style="text-align: center;" width="10%">操作</th>
        </tr>
        </thead>
        <tbody>

            {volist name="cate" id="c"}
            <tr>
                <td style="text-align: center;">{$c.id}</td>
                <th style="text-align: center;" width="5%">
                  <!--排序inpunt输入框-->
                  <input type="text"  name="cate_sort[{$c.id}]" value="{$c.cate_sort}" style="width: 20px;height: 20px;text-align: center;color: #333333;"/>
                </th>
                <td><?php echo str_repeat('———',$c['level']*1); ?>{$c.name}</td>
                <td style="text-align: center;"><img src="{$c.image}" style="height: 40px;"/></td>
                <td style="text-align: center;">
                    {if condition="$c.cate_type eq 1 "}列表页面{/if}
                    {if condition="$c.cate_type eq 2 "}频道页面{/if}
                    {if condition="$c.cate_type eq 3 "}单独页面{/if}
                </td>
                <td style="text-align: center;">{$c.cate_model}</td>
                <td style="text-align: center;"> <button spanid="{$c.id}" onclick="status(this)" type="button" class="{if condition=" $c.status eq 1 "}layui-btn layui-btn-xs layui-btn-normal {else /} layui-btn layui-btn-xs layui-btn-danger {/if}">
                    {if condition="$c.status eq 1 "}启用{else /}禁用{/if}
                    </button></td>
                <td style="text-align: center;">
                    <a title="编辑"  onclick="MT_open('编辑','edit?id={$c.id}')" href="javascript:;" class="layui-btn layui-btn-xs">编辑</a>
                    <a title="删除" onclick="member_del(this,'{$c.id}')" href="javascript:;" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
                </td>
            </tr>
            {/volist}

        </tbody>
    </table>
</div>
</form>
//  排序PHP
      public function csort(){
         if (request()->isPost()){
            $data = input('post.');
            foreach ($data as $k=>$v){
               foreach ($v as $i=>$s){
                  $res = db('cate')->where('id',$i)->update([$k=>$s]);
               }
            }
            if ($res){
               $this->redirect('cate_list');
            }else{
               $this->redirect('cate_list');
            }
         }
      }

记录一下ThinkPHP实现排序功能代码……

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post