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>

最新文章

  1. android 之 启动画面的两种方法
  2. Tomcat目录映射设置
  3. Mac mysql修改密码
  4. hack是什么
  5. bat产生随机数并复制文件及生成文件列表
  6. html5页面中拨打电话的方式
  7. 快速建立Linux c/c++编译环境
  8. Objective-C之消息机制
  9. 设计模式 Mixin (混入类)
  10. javascriptDOM编程艺术_学习笔记_知识点 动态创建标记
  11. 如何让HTML在手机上实现直接拨打电话以及发送短信?
  12. JS中Exception处理
  13. 日常踩坑 searter
  14. kickstart 实现批量安装centos7.x系统
  15. [GitHub]第六讲:开源项目贡献流程
  16. PHP内核之旅-3.变量
  17. 02 入门 - ASP.NET MVC 5 概述
  18. linux网络性能测试工具ipref安装与使用
  19. Linux(Ubuntu 16) 下Java开发环境的配置(一)------JDK的配置
  20. 【转载】阿里云Windows服务器快速部署PHP运行环境

热门文章

  1. Spring基础系列--AOP实践
  2. ZooKeeper的三种典型应用场景
  3. .Net语言 APP开发平台——Smobiler学习日志:基于Access数据库的Demo
  4. [T-SQL] NCL INDEX 欄位選擇效能影響-解析
  5. Powerdesigner逆向工程64位Oracle数据库
  6. 【转】C#中判断网址是否有效
  7. C# 实现对PPT文档加密、解密以及重置密码的操作
  8. Java开发笔记(四十)日期与字符串的互相转换
  9. Linux驱动学习1.hello world;
  10. C#从SqlServer数据库读写文件源码