莱州网站建设包年多少钱,吃的网站要怎么做的,重庆市公司网站备案在哪了,二手交易网站开发上一篇说了怎么查看帖子,这一篇就来说说怎么把数据库里面的帖子提取出来编辑.代码逻辑是这样的:先验证是否是当前用户的帖子,是的话就提供编辑按钮,这个在view.php中实现.-在数据库中根据get的a来提取已有帖子数据,加载到模板文件中.-最后把得到数据更新到数据库里面,再…上一篇说了怎么查看帖子,这一篇就来说说怎么把数据库里面的帖子提取出来编辑.代码逻辑是这样的:先验证是否是当前用户的帖子,是的话就提供编辑按钮,这个在view.php中实现.-在数据库中根据get的a来提取已有帖子数据,加载到模板文件中.-最后把得到数据更新到数据库里面,再跳转到查看帖子edit.phpinclude(conn.php);include(lib.php);include(ChromePhp.php);session_start();// Chromephp::log($_SESSION[uid]);// Chromephp::log($_SESSION[name]);//如果会话没有被设置查看是否设置了cookieif(!isset($_SESSION[uid])){if(isset($_COOKIE[uid])isset($_COOKIE[name])){//用cookie给session赋值$_SESSION[uid]$_COOKIE[uid];$_SESSION[name]$_COOKIE[name];}else{header(Location: login.php);exit();}}//获取分类目录if($_SERVER[REQUEST_METHOD] GET){$aid$_GET[a];$sqlselect id, name from categories;$querymysql_query($sql);while ($nodemysql_fetch_assoc($query)) {$category[$node[id]]$node[name];}//提取已有的帖子内容$querymysql_query(select * from articles where id$aid);$articlemysql_fetch_array($query);ChromePhp::log($article);include(templates/edit.php);}if($_SERVER[REQUEST_METHOD] POST){//header(Location: index.php) ;//print_r($category);$aid$_GET[a];$titleformat($_POST[title]);$contentformat($_POST[content]);$classicformat($_POST[classic]);//ChromePhp::log($classic);//更新分类文章数量$sqlupdate categories set articles articles1 where name $classic;$querymysql_query($sql);//ChromePhp::log($query);$timetime();//ChromePhp::log($aid);//上传图片if ($_FILES[img][error] 0 ($_FILES[img][type]image/gif|| $_FILES[img][type]image/jpeg || $_FILES[img][type]image/pjpeg|| $_FILES[img][type]image/png)){//判断错误代码0则上传成功0则上传失败//处理上传过程// ChromePhp::log(开始上传);$img $_FILES[img];//header(Location: templates/error.php) ;//exit;//拼接文件路径$path upload/.mk_dir()./.randName(). . .getExt($img[name]);// ChromePhp::log($path);//移动if(move_uploaded_file($img[tmp_name],$path)) {mysql_query(update articles set title$title, content$content, category$classic, edittime$time, img_path$path where id$aid);header(Location: view.php?a.$aid);exit();} else{ChromePhp::log(上传失败);}}else{mysql_query(update articles set title$title, content$content, category$classic, edittime$time, img_path$path where id$aid);// $url http://blog.csdn.net/abandonship;// echo // echo window.location.href$url;// echo ;header(Location: view.php?a.$aid);exit();// ChromePhp::log($_FILES[img][error]);}}?templates/edit.php返回编辑逗贴enctypemultipart/form-data data-ajaxfalse ; ?标题 内容请选择分类foreach ($category as $id $name) {echo ,$name,;}?图片: