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]}' onclick=\"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>

PHP 练习(新闻发布)的更多相关文章

  1. 【NodeJS 学习笔记04】新闻发布系统

    前言 昨天,我们跟着这位大哥的博客(https://github.com/nswbmw/N-blog/wiki/_pages)进行了nodeJS初步的学习,最后也能将数据插入数据库了 但是一味的跟着别 ...

  2. News新闻发布系统

            News新闻发布系统分页的实现 1.首先我们要在NewsDAO中创建一个方法,返回List<NewsEntity>集合,其中pageIndex表示当前页,pageSize表 ...

  3. 2016.6.23 PHP实现新闻发布系统主体部分

    1.新闻发布系统的列表: <html><meta http-equiv="Content-Type" content="text/html; chars ...

  4. DRP PK 牛腩新闻发布系统

    一.JSP与ASP (1)Web服务器的支持:大多数通用的Web服务器如:Apache.Netscape和Microsoft IIS都支持JSP页面,只有微软本身的Microsoft IIS和Pers ...

  5. 安卓项目-利用Sqlite数据库,开发新闻发布系统

    本教程致力于程序员可以快速的学习安卓移动端手机开发. 适合于已经习得一种编程语言的同仁. 更多志同道合,想要学习更多编程技术的大神们. 小弟不才,麻烦关注一下我的今日头条号-做全栈攻城狮. 本文章是基 ...

  6. 牛腩新闻发布系统--学习Web的小技巧汇总

    2014年11月10日,是个难忘的日子,这一天,小编的BS学习开始了,BS的开头,从牛腩新闻发布系统开始,之前学习的内容都是CS方面的知识,软考过后,开始学习BS,接触BS有几天的时间了,跟着牛腩老师 ...

  7. PHP 练习1:新闻发布

    1.新闻发布主页面 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://w ...

  8. j2ee期末项目 新闻发布系统需求文档

    1 绪论 1.1 开发背景 现如今社会是信息化的社会,掌握的信息越多越全面越快速的人,就会在各方面的竞争当中,占据优势,正所谓知己知彼百战不殆,信息的不对称性将会是失败的主要诱因之一.信息的时效性越来 ...

  9. 新闻发布系统<分页>

    分页实现: 实现数据的分页显示,需要以下几个关键步骤: ①确定每页显示的总页数 ②计算显示的总页数 ③编写SQL语句 实现效果如图所示: 当点击下一页时,地址栏地址为?pageIndex=2 1.创建 ...

随机推荐

  1. Git合并不同url的项目

    本文由云+社区发表 作者:工程师小熊 摘要:为了让项目能实现Git+Gerrit+Jenkin的持续集成,我们把项目从Git上迁移到了Gerrit上,发现有的同事在老Git提交代码,因为Gerrit做 ...

  2. Django学习笔记(1)——初识Django

    一:Web框架介绍 框架,即framework,特指为解决一个开放性问题而设计的具有一定约束性的支撑结构,使用框架可以快速帮你开发特定的系统. Web框架是别人已经设定好的一个web网站模板,你学习它 ...

  3. 第10章 使用密码保护API - Identity Server 4 中文文档(v1.0.0)

    OAuth 2.0资源所有者密码授权允许客户端向令牌服务发送用户名和密码,并获取代表该用户的访问令牌. 除了无法承载浏览器的旧应用程序之外,规范通常建议不要使用资源所有者密码授予.一般来说,当您要对用 ...

  4. 斐波那契数列 (C#)

    斐波那契数列(Fibonacci sequence),又称黄金分割数列.因数学家列昂纳多·斐波那契(Leonardoda Fibonacci)以兔子繁殖为例子而引入,故又称为“兔子数列”,指的是这样一 ...

  5. Linux万能快捷键与命令

    tab键:补全命令 \ :命令折行写 Ctrl+C :结束命令 --help :查看命令详细信息 man :类似于help 比help更加详细. sudo :临时以管理员权限执行命令. 还有吗?

  6. [PHP] 魔术方法__get __set __sleep __wakeup的实际使用

    1.__get __set是在给不可访问属性赋值和读取时,调用 2.__sleep 是在序列化对象的时候调用 3.__wakeup是在反序列化对象的时候调用 4.可以在序列化对象的时候 , 只序列化指 ...

  7. Java开发笔记(四十九)关键字super的用法

    前面介绍了如何从Bird类继承而来Swallow类,按道理子类应当继承父类的所有要素,但是对于构造方法来说,Swallow类仅仅继承了Bird类的默认构造方法,并未自动继承带参数的构造方法.如果子类想 ...

  8. 前端入门13-JavaScript进阶之原型

    声明 本系列文章内容全部梳理自以下几个来源: <JavaScript权威指南> MDN web docs Github:smyhvae/web Github:goddyZhao/Trans ...

  9. 使用 CODING 进行 Spring Boot 项目的集成

    本文作者:CODING 用户 - 高文 持续集成 (Continuous integration) 是一种软件开发实践,即团队开发成员经常集成他们的工作,通过每个成员每天至少集成一次,也就意味着每天可 ...

  10. Dynamics 365出现数据加密错误怎么办?

    本人微信公众号:微软动态CRM专家罗勇 ,回复290或者20181227可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me . Dy ...