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:新闻发布的更多相关文章

  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.新闻发布主页面 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://w ...

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

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

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

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

随机推荐

  1. 开启假期JAVA之路

    . 从最基础的JAVA开始学起,已经上了三节课啦!希望在课程结束后能完成一个令自己满意的连连看项目,期待ing~ 慢慢的从简单的代码上手了~ . 用循环输出等腰三角形的效果 import java.u ...

  2. windows编程了解

    文章:浅谈Windows API编程 (这个经典)

  3. lintcode-34-N皇后问题 II

    34-N皇后问题 II 根据n皇后问题,现在返回n皇后不同的解决方案的数量而不是具体的放置布局. 样例 比如n=4,存在2种解决方案 标签 递归 思路 参考http://www.cnblogs.com ...

  4. TCP系列03—连接管理—2、TCP连接的同时打开和同时关闭

    在前面的内容中我们介绍了TCP连接管理中最常见的三次握手方式和四次挥手的方式.但是有可能A和B两端同时执行主动打开并连接对方或者同时执行主动关闭连接(尽管发生这种情况的可能性比较低低),这个时候的流程 ...

  5. 原生javascript自定义input[type=radio]效果

    2018年6月27日 更新 找到最为简单的仅仅使用css3的方案 <!DOCTYPE html> <html lang="en"> <head> ...

  6. ubuntu 安装lua错误

    转自:http://www.cnblogs.com/softidea/archive/2016/03/02/5236498.html lua.c:80:31: fatal error: readlin ...

  7. [Redis]在Windows下的下载及安装

    1.下载 下载地址: https://github.com/MSOpenTech/redis, 下载并解压到特定的目录. 2.启动Redis服务端 CMD -> redis-server.exe ...

  8. VS05错误:部署WEB文件失败

    直接生成一个空项目就不存在这个问题了.

  9. Python替换字符串中的反斜杠\

    s = 'cdp\nd' result = eval(repr(s).replace('\\', '@')) print(result) repr() 函数可以将字符串转换为python的原始字符串( ...

  10. Square Root of Permutation - CF612E

    Description A permutation of length n is an array containing each integer from 1 to n exactly once. ...