森
Follow

After following, you can keep track of his dynamic information in a timely manner

Course notes
  • Courses in the relevant section:Column display sorting

    循环排序:public function sort(){ // dump($_POST);die; $cate=D('cate'); foreach ($_POST as $id => $sort) { // UPDATE `blog`.`blog_cate` SET `sort` = '5' WHERE `blog_cate`.`id` =5; // $cate->where(array('id'=>$id))->setField('sort',$sort); $cate->where('id='.$id)->setField('sort',$sort); } // dump($_POST);die; $this->success('排序成功',U('lst')); }

    2017-10-121个赞

  • Courses in the relevant section:Column modification and deletion

    CONTROLLER: public function sort(){ // dump($_POST);die; $cate=D('cate'); foreach ($_POST as $id => $sort) { // UPDATE `blog`.`blog_cate` SET `sort` = '5' WHERE `blog_cate`.`id` =5; // $cate->where(array('id'=>$id))->setField('sort',$sort); $cate->where('id='.$id)->setField('sort',$sort); } // dump($_POST);die; $this->success('排序成功',U('lst')); }

    public function edit(){ $cate=D('cate'); if(!IS_POST){//如果没有点击提交 $cater=$cate->find(I('id')); }else{ $date['id']=I('id'); $date['catename']=I('catename'); // dump($date);die; if($cate->create($date)){ if($cate->save()){ $this->success('修改栏目成功',U('lst')); }else{ $this->error('修改栏目失败'); } }else{ $this->error($cate->getError()); } return; } $this->assign('cater',$cater); $this->display(); }

    2017-10-121个赞