After following, you can keep track of his dynamic information in a timely manner
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个赞
Courses in the relevant section:Overview of ThinkPHP5 framework: quickly enter the world of TP
入口文件位置的设计是为了让应用部署更安全,public目录为web可访问目录,其他的文件都可以放到非WEB访问目录下面。
2017-09-260个赞