PHP 练习(新闻发布)
1.新闻发布主页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style> *{ margin:0px auto; padding:0px} </style> </head> <body> <form action="newstijiao.php" method="post"> <div style="width:500px; height:400px; position:relative"> <div style="font-size:16px; text-align:center; padding-top:20px">发布新闻</div> <div style="margin-top:20px">标题:<input name="title" type="text" style="width:240px; height:20px; margin-left:10px" /></div> <div style="margin-top:10px">作者:<input name="author" type="text" style="width:150px; height:20px; margin-left:10px" /></div> <div style="margin-top:10px">来源:<input name="source" type="text" style="width:150px; height:20px; margin-left:10px" /></div> <div style="margin-top:10px">内容:<input name="content" type="textarea" style="width:420px; height:120px; margin-left:10px" /></div> <div style="float:left; margin-left:200px"><input type="submit" value="提交" style="width:50px; height:30px; margin-top:10px" /></div> <form action="newsmain.php"> <div style="float:left"><input type="submit" value="查看" style="margin-top:10px; width:50px; height:30px; margin-left:10px" /></div> </form> </div> </form> </body> </html>
页面显示:
2.新闻提交处理页面
<?php $newsid = ""; $title = $_POST["title"]; $author = $_POST["author"]; $source = $_POST["source"]; $content = $_POST["content"]; $time = date('y-m-d h:i:s',time()); echo $title; //造连接对象 $db = new MySQLi("localhost","root","666","newssystem"); $sql = "insert into news values('{$newsid}','{$title}','{$author}','{$source}','{$content}','{$time}')"; $db->query($sql); header("location:newsmain.php");
3.页面提交至新闻列表页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>newsid</td> <td>title</td> <td>Author</td> <td>source</td> <td>content</td> <td>time</td> <td>update</td> <td>delete</td> </tr>
<?php $db = new MySQLi("localhost","root","666","newssystem");$sql = "select * from news"; $result = $db->query($sql); $attr = $result->fetch_all(); foreach($attr as $v) { echo "<tr>"; echo"<td>{$v[0]}</td><td>{$v[1]}</td><td>{$v[2]}</td><td>{$v[3]}</td><td>{$v[4]}</td><td>{$v[5]}</td><td><a href='newsupdate.php?c={$v[0]}')\">update</a></td><td><a href='newsdelete.php?c={$v[0]}' οnclick=\"return confirm('确定删除吗?')\">delete</a></td>"; } ?>
</table> </body> </html>
页面显示为
4.删除处理页面
<?php $newsid = $_GET["c"]; $db = new MySQLi("localhost","root","666","newssystem"); $sql = "delete from news where newsid='{$newsid}'"; $r = $db->query($sql); if($r) { header("location:newsmain.php"); } else { echo "删除失败"; }
5.提交处理页面
<?php $newsid = $_POST["newsid"]; $title = $_POST["title"]; $author = $_POST["author"]; $source = $_POST["source"]; $content = $_POST["content"]; $time = date('y-m-d h:i:s',time()); $db = new MySQLi("localhost","root","666","newssystem"); $sql = "update news set title='{$title}',author='{$author}',source='${source}',content='${content}',time='{$time}' where newsid='{$newsid}'"; $db->query($sql); header("location:newsmain.php");
6.修改处理页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style> *{ margin:0px auto; padding:0px} </style> </head> <body>
<?php $newsid = $_GET["c"]; $db = new MySQLi("localhost","root","666","newssystem"); $sql = "select * from news where newsid='{$newsid}'"; $result = $db->query($sql); $attr = $result->fetch_all(); foreach($attr as $a) { }
?> <form action="newstijiaochuli.php" method="post"> <div style="width:500px; height:400px; position:relative"> <div style="font-size:16px; text-align:center; padding-top:20px">发布新闻</div> <div style="margin-top:20px"><input value="<?php echo $a[0] ?>" name="newsid" type="hidden" /></div> <div style="margin-top:20px">标题:<input value="<?php echo $a[1] ?>" name="title" type="text" style="width:240px; height:20px; margin-left:10px" /></div> <div style="margin-top:10px">作者:<input value="<?php echo $a[2] ?>" name="author" type="text" style="width:150px; height:20px; margin-left:10px" /></div> <div style="margin-top:10px">来源:<input value="<?php echo $a[3] ?>" name="source" type="text" style="width:150px; height:20px; margin-left:10px" /></div> <div style="margin-top:10px">内容:<input value="<?php echo $a[4] ?>" name="content" type="textarea" style="width:420px; height:120px; margin-left:10px" /></div> <div style="float:left; margin-left:200px"><input type="submit" value="修改" style="width:50px; height:30px; margin-top:10px" /></div> <form action="newsmain.php"> <div style="float:left"><input type="submit" value="查看" style="margin-top:10px; width:50px; height:30px; margin-left:10px" /></div> </form> </div> </form> </body> </html>
转载于:https://www.cnblogs.com/l5580/p/6065594.html
PHP 练习(新闻发布)相关推荐
- 【牛腩新闻发布系统】开发前的准备01
前言: 牛腩新闻发布系统已经完成了很久了,在完成的过程中,一步步按照视频的步骤在走,中间探索了一下注释部分是怎么出来的.整个学习过程紧凑而且有序,中间也拖沓了两周有开始接着完成,接下来是整个过程中一些 ...
- 新闻更新php html,phphtml 新闻发布系统,运用php+mysql,里面包括数据库和php文件。 Other systems 其他 249万源代码下载- www.pudn.com...
文件名称: phphtml下载 收藏√ [ 5 4 3 2 1 ] 开发工具: PHP 文件大小: 1076 KB 上传时间: 2016-01-07 下载次数: 0 提 供 者: zfl ...
- 牛腩新闻发布系统——后台前台整合技术
在牛腩新闻发布系统中用到了一些技术我就来总结下 一.鼠标超链接设置 一开始就用到了鼠标超链接的设置.尾部样式的设置,这个东西每个网站都要用到非常长用所以可以写下来积累积累. 举个例子 如图:鼠标没有移 ...
- 【NodeJS 学习笔记04】新闻发布系统
前言 昨天,我们跟着这位大哥的博客(https://github.com/nswbmw/N-blog/wiki/_pages)进行了nodeJS初步的学习,最后也能将数据插入数据库了 但是一味的跟着别 ...
- DayDayUp:哈哈,你上榜了嘛?界面新闻发布2020年中国最富1000人榜,总财富增加28%
DayDayUp:哈哈,你上榜了嘛?界面新闻发布2020年中国最富1000人榜,总财富增加28% 导读:今年榜单中1000位富豪的财富总额相比去年增长了3.14万亿元,增幅28.31%,近六成富豪的财 ...
- asp版新闻发布今日弄好
感谢组长帮忙弄好了新闻发布的删除功能,组长自己那么多事,而且又是凌晨二点,仍过来帮我解决问题.太感激了.... 最近特别忙,也让我多了些怨天尤人的感慨.其实还是自己的原因,如果我能力足够强的话,会轻松 ...
- 新闻发布项目——数据库脚本(直接导入即可)
数据库sql servel 2012版本,以下是脚本: USE [master] GO /****** Object: Database [newsDB] Script Date: 2016/11/2 ...
- 新闻发布项目——访问温馨提示
1.本项目开发的软件:MyEclipse10.0+tomcat7.0+sql servel2012 2.本项目所有的CSS下载地址:Jsp实现新闻发布系统的CSS界面 3.本项目所有的JS下载地址:J ...
- 新闻发布系统java ee_Java EE 7发布–反馈和新闻报道
新闻发布系统java ee Java EE 7已经存在了几天. 我们所有人都有机会观看直播活动或可用的重播 . 最后的MR版本完成了将其工作推向JCP的工作,基本上是一个总结. 是时候反思发生的事情和 ...
- 百家号 不被推荐,原因:将旧闻冒充新闻发布,请修改后重新发布
1.情景展示 在百家号进行创作的作者,发布文章时,难免会遇到审核不通过,下面说一下其中一种情况: 不被推荐,原因:将旧闻冒充新闻发布,请修改后重新发布. 2.解决方案 出现这种情况,原因:其它平台已存 ...
最新文章
- 美多后台管理和项目环境搭建
- EXCEL利用VBA自由控制图表绘图区大小
- 初步认识深度学习笔记(一)
- linux中查看文件指定行的数据
- php求及格,详解PHP通过递归实现提成计算
- [python作业AI毕业设计博客]比Selenium IDE更好用的录制工具: Katalon Recorder
- 《世界已无法阻挡Python入侵!》(附学习资源)
- IOS自动化打包平台
- 【入门篇】黑盒测试基础
- Sql Server 的sa用户被禁用
- 用Python开始机器学习(2:决策树分类算法)
- How to root android Oppo A11w,OPPO R11系列 解锁Bootloader 救砖 TWRP Recovery ROOT 详细教程 亲测[推荐]...
- 天正电气图例_天正电气CAD教程之文件布图篇(内附往期秘籍)
- web前端响应式设计总结
- h5、微信、app互相跳转
- Java-按照指定小时分割时间段
- 性能测试结果分析思路
- Kerberos (一) --------- Kerberos 部署
- 数分钟完成报销 SAP Concur帮助开德阜实现高效费用管理
- 关于uni-app手机nfc开启、读取、写入功能