php文章管理模块实例代码_第1页
php文章管理模块实例代码_第2页
php文章管理模块实例代码_第3页
php文章管理模块实例代码_第4页
php文章管理模块实例代码_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

php文章管理模块实例代码php写的文章管理模块,包括添加文章、修改与删除文章、查看文章列表等,有需要的朋友,可以作个参考。代码如下,实现了文章管理的基本功能,大家注意看注释,知识点还是不少的。BasePath = ./FCKeditor/; / 设置FCKeditor目录地址 /*action操作初始化*/ if(emptyempty($_REQUESTaction) $_REQUESTaction=list; else $_REQUESTaction=trim($_REQUESTaction); if($_REQUESTaction=add) $oFCKeditor = new FCKeditor(content) ; / 创建FCKeditor实例,可创建多个实例 $oFCKeditor-BasePath = ./FCKeditor/; / 设置FCKeditor目录地址 $tpl-assign(fck,$oFCKeditor-Create(); $tpl-assign(tmess,添加文章); $tpl-assign(act,insert); $tpl-assign(submitButton,添加); $tpl-display(admin/addArticle.tpl); /*添加文章*/ elseif ($_REQUESTaction=insert) $title=$_POSTtitle; $zhaiyao=$_POSTzhaiyao; $author=$_POSTauthor; $laiyuan=$_POSTlaiyuan; $keyword=$_POSTkeyword; $is_tuijian=$_POSTis_tuijian; $content=$_POSTcontent; $sql=insert into article (title,zhaiyao,author,laiyuan,keyword,is_tuijian,content,addtime) values ($title,$zhaiyao,$author,$laiyuan,$keyword,$is_tuijian,$content,now(); $rs=$db-query($sql); if($rs) echo header(location:/admin/article.php?action=list); else echo 失败!; /*文章列表*/ elseif ($_REQUESTaction=list) $total=getAllArticle(); $curpage=isset()($_GETpage)?$_GETpage:1; $pageObj=new Page($total,$curpage); $pageInfo=$pageObj-getPageInfo(); $arts=getArticlePage($pageInforow_offset,$pageInforow_num); $tpl-assign(tmess,文章列表); $tpl-assign(arts,$arts); $tpl-assign(pageInfo,$pageInfo); $tpl-display(admin/editArticle.tpl); /*修改文章*/ elseif ($_REQUESTaction=edit) $id=$_GETid; $post=editArticle($id); $tpl-assign(tmess,修改文章); $tpl-assign(post,$post); $oFCKeditor-Value=$postcontent; /编辑时显示文章内容 if($postis_tuijian=1|$_POSTrecommend=1) /判断是否推荐 $tpl-assign(recommend,checked); else $tpl-assign(no_recommend,checked); $tpl-assign(fck,$oFCKeditor-Create(); $tpl-assign(act,update); $tpl-assign(submitButton,修改); $tpl-display(admin/addArticle.tpl); elseif ($_REQUESTaction=update) $id=$_POSTid; $title=$_POSTtitle; $zhaiyao=$_POSTzhaiyao; $author=$_POSTauthor; $laiyuan=$_POSTlaiyuan; $keyword=$_POSTkeyword; $is_tuijian=$_POSTis_tuijian; $content=$_POSTcontent; $sql=update article set title=$title,zhaiyao=$zhaiyao,author=$author,laiyuan=$laiyuan,keyword=$keyword,is_tuijian=$is_tuijian, content=$content where id =$id; $rs=$db-query($sql); if($rs) echo header(location:/admin/article.php?action=list); else echo 修改失败!; /*删除*/ elseif ($_REQUESTaction=del) $id=$_GETid; del($id); /*审核文章*/ elseif ($_REQUESTaction=shenhe) $id=$_GETid; shenhe($id); /*锁定文章*/ elseif ($_REQUESTaction=lock) $id=$_GETid; lock($id); /*批量删除*/ /*批量审核*/ elseif (isset($_REQUESTshenhe_x)|isset($_REQUESTshenhe_y) $del=$_POSTdel; shenhe($del); /*批量锁定*/ elseif (isset($_REQUESTlock_x)|isset($_REQUESTlock_y) $del=$_POSTdel; lock($del); /*=-文章模块相关函数=*/ /* * 获取所有的文章进行分页用 * */ function getAllArticle() global $db; $sql=select * from article; $rs=$db-query($sql); $total=$db-num_rows($rs); return $total; /*文章分页相关函数*/ function getArticlePage($offset,$num) global $db; $sql=select*from article order by id desc limit $offset,$num; $rs=$db-query($sql); while ($row=$db-fetch_array($rs) $data=$row; return $data; /*文章修改*/ function editArticle($id) global $db; $sql=select * from article where id = $id; $rs=$db-query($sql); return $row=$db-fetch_array($rs,MYSQL_ASSOC); /*删除文章*/ function del($id) global $db; $sql=delete from article where id; if(is_array($id) $sql.=IN (.implode(,$id).); else $sql.=$id; $rs=$db-query($sql); if($rs) echo header(location:/admin/article.php?action=list); else echo 删除失败!; function shenhe($id) global $db; $sql=update article set status=1 where id; if(is_array($id) $sql.=IN (.join(,$id).); /如果$id是一个数组,用join函数把$id分割成用,连接的字符串 join是implode的别名 else $sql.=$id; $rs=$db-query($sql); if($rs) echo header(location:/admin/article.php?action=list); else echo 审核失败!; function lock($id) global $db; $sql=upda

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论