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. LintCode-71.二叉树的锯齿形层次遍历

    二叉树的锯齿形层次遍历 给出一棵二叉树,返回其节点值的锯齿形层次遍历(先从左往右,下一层再从右往左,层与层之间交替进行) 样例 给出一棵二叉树 {3,9,20,#,#,15,7}, 返回其锯齿形的层次 ...

  2. 【Linux】- 开启远程连接

    1.首先看看自己的Ubuntu是不是已经安装或启用了ssh服务,执行 ps -e |grep ssh 我们看到只有ssh-agent 这个是ssh-client客户端服务,如果有sshd,证明你已经装 ...

  3. VS升级后的配置问题

    当vs升级到更新的版本后,运行原来无误的程序会出现一系列问题. 例如:打不开iostream文件,lib文件,系统找不到文件等等 出现这类问题的原因是,编译环境的include path和librar ...

  4. 使用Windows Live Writer拉取之前写的博客

    因为之前写的博客有错误需要修改,但是在Windows Live Writer中找了半天也没找到怎么拉取之前的博客,在[打开本地草稿]或者[打开最近使用过的日志]中,由于存储的项数有限,所以就找不到那篇 ...

  5. SpringBoot2.0(三) 文件上传

    SpringBoot中发起文件上传示例: /** * 文件上传 * @param multipartFile * @param path * @return */ @RequestMapping(va ...

  6. bzoj3676-回文串

    给出一个字符串,一个子串的出现值为字串出现次数乘以长度,求所有回文串中最大的出现值. 分析 回文自动机模版题,建出自动机后直接统计即可. 回文自动机 类似于后缀自动机,不过一条边\((u,v,c)\) ...

  7. BZOJ4773 负环(floyd+倍增)

    倍增floyd求出经过<=2k条边时两点间最短路,一个点到自身的最短路就是包含该点的最小环.然后倍增找答案即可.注意初始时到自身的最短路设为0,这样求出的最短路就是经过<=2k条边的而不是 ...

  8. BZOJ4260 Codechef REBXOR(trie)

    用trie求出前缀最大区间异或和.后缀最大区间异或和即可.注意空间是nlog的. #include<iostream> #include<cstdio> #include< ...

  9. 【题解】SDOI2009Bill的挑战

    这题好像状压的做法比较的无脑?但想记录一下容斥的做法,感觉自己对于容斥简直一无所知.这道题目容斥的解法我也是看了题解才会的.如有雷同,是我看的(*/ω\*)我们可以首先枚举当前字符串与给定的哪 \(k ...

  10. [洛谷P3261][JLOI2015]城池攻占

    题目大意:有$n$个点的树,第$i$个节点有一个权值$h_i$,$m$个骑士,第$i$个骑士攻击力为$v_i$,一个骑士可以把从它开始的连续的父亲中比它小的节点攻破,攻破一个节点可以把攻击力加或乘一个 ...