thinkphp或thinkcmf 《文章编辑,文章添加》 访问另一个表的分类,添加入另一个表时将id值以(,)逗号分隔储存,编辑时以(,)逗号分隔并且相等的id值被选中

 
首页 显示 的控制器
//
网贷评级 public function grade(){ $archives = $this->archives_model->where(array('delete'=>0))->order(array('id' => 'desc'))->select(); //公司名称 $grade = $this->grade_model->where(array('delete'=>0))->order(array('id'=>'desc'))->select(); // 网贷数据 $this->assign('archives',$archives); //公司名称 $this->assign('grade',$grade); // 网贷数据 $this->display(); ========================分隔=========上面的是没有分页===============================================
$term_id = I('term'); if(!empty($term_id)){ $where['aid']=$term_id; } $keyword=I('keyword'); if(!empty($keyword)){ $where['aexpected'] = array('like',"%$keyword%"); /*$where['eiperiod'] = array('like',"%$keyword%"); $where['abidding'] = array('like',"%$keyword%");*/ } $start_time=I('start_time');//搜索开始时间 if(!empty($start_time)){ $where['updatetime']=array( array('EGT',$start_time) ); } $end_time=I('end_time');//搜索结束时间 if(!empty($end_time)){ if(empty($where['updatetime'])){ $where['updatetime']=array(); } array_push($where['updatetime'], array('ELT',$end_time)); } $archives= $this->archives_model->where(array('delete'=>0))->order(array('id'=>'desc'))->select(); $this->assign('archives',$archives); //查询archives表的分类 $count=$this->grade_model->where($where,array('delete'=>0))->count(); //查询boss表delete=>0的 总数 $page = $this->page($count, 20); //每页显示 1 条 $boss=$this->grade_model ->where($where,array('delete'=>0)) ->order(array('id'=>'desc')) ->limit($page->firstRow . ',' . $page->listRows) //引用cmf里封装好的方法 firstRow 和 listRows 我是这样理解的 ->select(); $this->assign("grade",$boss); //输出内容 $this->assign("page", $page->show("Admin")); //输出分页类 $this->assign("formget",array_merge($_GET,$_POST)); $this->display(); } 添加 - 文章 的控制器 //添加 网贷评级 //dump($acrights); public function addgrade(){ $archives = $this->archives_model->order(array('id' => 'desc'))->select(); //输出的是公司分类 $acrights = $this->acrights_model->select(); //输出的是债权转让 $plotfprmbgd = $this->plotformbgd_model->select();//输出的是平台背景 $guarantee = $this->guarantee_model->select();//输出的是保障模式 $features = $this->features_model->select(); //输出的是平台特征 $this->assign('archives',$archives);//输出的是公司分类 $this->assign('acrights',$acrights);//输出的是债权转让 $this->assign('plbgd',$plotfprmbgd);//输出的是平台背景 $this->assign('guar',$guarantee);//输出的是保障模式 $this->assign('features',$features);//输出的是平台特征 $this->display(); } public function addgrade_post(){ if (IS_POST) { if(empty($_POST['arc_id'])){ $this->error("请选择此资料属于哪家公司!"); } if(empty($_POST["hts_id"])){ $this->error("请至少选择一个债权转让类型"); } $str = implode(',',$_POST["hts_id"]); $guar = implode(',',$_POST["guar"]); $plbgd = implode(',',$_POST["plbgd"]); $features = implode(',',$_POST["features"]); //$this->error('ids:'.$str); $aid=I('arc_id');//分类公司 id $grade=I("post.post"); $grade['updatetime'] = date("Y-m-d H:i:s",time()); $grade['caeatetime'] = date("Y-m-d H:i:s",time()); $grade['delete']=0; $grade['aid']=$aid; $grade['acrights'] = $str; //债权转让类型 $grade['guarantee'] = $guar; //保障模式分类 $grade['platformbgd'] = $plbgd; //平台背景 $grade['pfeatures'] = $features; //平台特征 $result=$this->grade_model->add($grade); if ($result) { $this->success("添加成功!"); } else { $this->error("添加失败!"); } } }

 

 

文章添加的html页面

 

 

点击编辑 显示内容的控制器

public
function grade_edit(){ $id = I('get.id',0,'intval'); $grade = $this->grade_model->where("id=$id")->find(); //输出的是评级表 $grade['abcde'] = explode(',',$grade['acrights']); $grade['guar'] = explode(',',$grade['guarantee']); $grade['plbgd'] = explode(',',$grade['platformbgd']); $grade['pfea'] = explode(',',$grade['pfeatures']); /*dump($grade);die();*/ $archives = $this->archives_model->select(); //输出的是公司分类 $acrights = $this->acrights_model->select(); //输出的是债权转让 $plotfprmbgd = $this->plotformbgd_model->select();//输出的是平台背景 $guarantee = $this->guarantee_model->select();//输出的是保障模式 $features = $this->features_model->select(); //输出的是平台特征 $this->assign('post',$grade); //输出的是评级表 $this->assign('archives',$archives);//输出的是公司分类 $this->assign('acrights',$acrights);//输出的是债权转让 $this->assign('plbgd',$plotfprmbgd);//输出的是平台背景 $this->assign('guar',$guarantee);//输出的是保障模式 $this->assign('features',$features);//输出的是平台特征 $this->display(); }

提交编辑好的内容 控制器
public function grade_edit_post(){ if (IS_POST) { if(empty($_POST['arc_id'])){ $this->error("请选择此资料属于哪家公司!"); } if(empty($_POST["hts_id"])){ $this->error("请至少选择一个债权转让类型"); } $str = implode(',',$_POST["hts_id"]); $guar = implode(',',$_POST["guar"]); $plbgd = implode(',',$_POST["plbgd"]); $features = implode(',',$_POST["features"]); //$this->error('ids:'.$str); //$_POST['post']['cid']=get_current_admin_id(); $aid=I('arc_id');//分类公司 $grade=I("post.post"); $grade['updatetime'] = date("Y-m-d H:i:s",time()); $grade['caeatetime'] = date("Y-m-d H:i:s",time()); $grade['delete']=0; $grade['aid']=$aid; $grade['acrights'] = $str; //债权转让类型 $grade['guarantee'] = $guar; //保障模式分类 $grade['platformbgd'] = $plbgd; //平台背景 $grade['pfeatures'] = $features; //平台特征 $result=$this->grade_model->save($grade); if ($result!==false) { $this->success("修改成功!"); } else { $this->error("修改失败!"
); } } }

 

posted @ 2017-04-27 17:06  遇事稳坐钓鱼台  阅读(322)  评论(0编辑  收藏  举报