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. Runloop详解

    RunLoop是iOS和OSX开发中非常基础的一个概念,这篇文章将从源码以及应用入手,介绍RunLoop的概念以及底层实现原理.本人看了一下RunLoop的英语源码,以及借鉴部分优秀博客,感谢!读完这 ...

  2. 第48章 UserInfo端点(UserInfo Endpoint) - Identity Server 4 中文文档(v1.0.0)

    UserInfo端点可用于检索有关用户的身份信息(请参阅规范). 调用者需要发送代表用户的有效访问令牌.根据授予的范围,UserInfo端点将返回映射的声明(至少需要openid作用域). 示例 GE ...

  3. Python批量修改寄存器的值

    在写代码过程中,我们修改代码中寄存器的值,但是有时寄存器的数据较多,手动修改容易出现错误而且花费的时间长 这是一段寄存器的配置值: 0x00, 0x34  0x35, 0x25  0x10, 0xd4 ...

  4. 百度图片objURL解密vb.net版

    Function Baidtu_Uncomplie(k As String) As String Dim c = {"_z2C$q", "_z&e3B" ...

  5. 微信小程序支付接入注意点

    一.微信支付后台服务器部署 服务器采用ubuntu16.04 + php7.0 + apache2.0. 微信支付后台服务使用了curl 和 samplexml ,因此php.ini配置中必须开启这两 ...

  6. js cookie存取

    if(getCookie('guide') == 'true'){ window.location.href='' } else { setCookie('guide','true'); } func ...

  7. Dynamics CRM项目实例之六:积分管理,汇总字段,计算字段,快速查看视图

    关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复137或者20141228可方便获取本文,同时可以在第一时间得到我发布的最新的博文信息,follow me!        博文讲述的主要是如 ...

  8. 无依赖简单易用的Dynamics 365实体记录数计数器并能计算出FetchXml返回的记录数

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

  9. AI时代大点兵-国内外知名AI公司2018年最新盘点

    AI时代大点兵-国内外知名AI公司2018年最新盘点 导言 据腾讯研究院统计,截至2017年6月,全球人工智能初创企业共计2617家.美国占据1078家居首,中国以592家企业排名第二,其后分别是英国 ...

  10. 0.react学习笔记-环境搭建与脚手架

    0.环境搭建 笔者使用的是deepin/mac两种系统,因为两个电脑经常切换用.环境搭建没什么区别. 0.1 node安装 按照node官网叙述安装 # Using Debian, as root c ...