<!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 type="text/css">
#a
{
    height:20px;
    width:80px;
    top:80px;
    left:420px;
    position:absolute;
    border:1px;

}
#b
{
    height:20px;
    width:80px;
    top:110px;
    left:420px;
    position:absolute;
    border:1px;

}
#c
{
    height:20px;
    width:80px;
    top:140px;
    left:420px;
    position:absolute;
    border:1px;

}
#d
{
    height:20px;
    width:80px;
    top:260px;
    left:420px;
    position:absolute;
    border:1px;

}
#aa
{
    height:20px;
    width:160px;
    top:100px;
    left:490px;
    position:absolute;
    border:1px;

}
#bb
{
    height:20px;
    width:80px;
    top:130px;
    left:490px;
    position:absolute;
    border:1px;

}
#cc
{
    height:20px;
    width:80px;
    top:160px;
    left:490px;
    position:absolute;
    border:1px;

}
#dd
{
    height:20px;
    width:240px;
    top:190px;
    left:490px;
    position:absolute;
    border:1px;

}
#f
{
    width:40px;
    height:20px;
    left:540px;
    top:420px;
    position:absolute;
    
}
#ff
{
    width:40px;
    height:20px;
    left:820px;
    top:420px;
    position:absolute;
    
}
</style>
</head>

<body>
<form action="xwup.php" method="post">
<center><h1>发布新闻</h1></center>
<div id="a"><h3>标题:</h3></div>
<div id="aa"><input type="text" name="title" style="width:300px" /></div>
<div id="b"><h3>作者:</h3></div>
<div id="bb"><input type="text" name="author" width="80px" /></div>
<div id="c"><h3>来源:</h3></div>
<div id="cc"><input type="text" name="source"  width="80px"/></div>
<div id="d"><h3>内容:</h3></div>
<div id="dd"><textarea name="content" cols="50" rows="10" style="resize:none"></textarea>
</div>
<div id="f"><input type="submit" name="tijia" value="提交"/></div>
<div id="ff"><a href="xwck.php"><input type="button" name="chakan" value="查看"/></a></div>
</form>

</body>
</html>
xwzy
<!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>
<?php
    
    $title = $_POST["title"];
    $author = $_POST["author"];
    $source = $_POST["source"];
    $content = $_POST["content"];
    
    $new = new MySQLi("localhost","root","ck","newssystem");
    $date = date("Y-m-d H:i:s");
    if(mysqli_connect_error())
    {
        echo "链接失败";
        exit;
    }
    {
        $sql = "insert into news values('','{$title}','{$author}','{$source}','{$content}','{$date}')";
        $result = $new->query($sql);
        if($result)
        {
            header("Location:xwzy.php");
        }
        else
        {
            echo "添加失败";
        }
    }

?>

</body>
</html>
xwup
<!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>
<?php
    $xw=new MySQLi("localhost","root","ck","newssystem");
    if(mysqli_connect_error())
    {
        echo"链接失败";
        exit;
    }
    else
    {
        $spl="select * from news";
        $xwspl=$xw->query($spl);
        echo"<table width=100% cellpadding='0' cellspacing='0' border='1'>";
        echo"<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>";;    
        while($row=$xwspl->fetch_row())
        {
            echo"<tr><td>{$row[0]}</td><td>{$row[1]}</td><td>{$row[2]}</td><td>{$row[3]}</td><td>{$row[4]}</td><td>{$row[5]}</td><td><a href='xwxgzy.php?newid=".$row[0]."'>update</a></td><td><a href='xwdn.php?newid=".$row[0]."'>delete</a></td></tr>";            
        }
        echo"</table>";
    }

?>
<div><a href="xwzy.php"><form><input  type="button" value="返回"/></form></a></div>
</body>
</html>
xwck
<?php
    $newsid = $_GET["newid"];
    $news = new mysqli("localhost","root","ck","newssystem");
    if(mysqli_connect_error())
    {
        echo "链接失败";
        exit;
    }
    else
    {
        $sql = "delete from news where newsid = '".$newsid."'";
        $result = $news->query($sql);
        if($result)
        {
            header("Location:xwzy.php");
        }
        else
        {
            echo "删除失败";
        }
    }
?>
xwdn
<!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 type="text/css">
#a
{
    height:20px;
    width:80px;
    top:80px;
    left:420px;
    position:absolute;
    border:1px;

}
#b
{
    height:20px;
    width:80px;
    top:110px;
    left:420px;
    position:absolute;
    border:1px;

}
#c
{
    height:20px;
    width:80px;
    top:140px;
    left:420px;
    position:absolute;
    border:1px;

}
#d
{
    height:20px;
    width:80px;
    top:260px;
    left:420px;
    position:absolute;
    border:1px;

}
#aa
{
    height:20px;
    width:160px;
    top:100px;
    left:490px;
    position:absolute;
    border:1px;

}
#bb
{
    height:20px;
    width:80px;
    top:130px;
    left:490px;
    position:absolute;
    border:1px;

}
#cc
{
    height:20px;
    width:80px;
    top:160px;
    left:490px;
    position:absolute;
    border:1px;

}
#dd
{
    height:20px;
    width:240px;
    top:190px;
    left:490px;
    position:absolute;
    border:1px;

}
#f
{
    width:40px;
    height:20px;
    left:540px;
    top:420px;
    position:absolute;
    
}
#ff
{
    width:40px;
    height:20px;
    left:820px;
    top:420px;
    position:absolute;
    
}
</style>
</head>
<?php

$id=$_GET["newid"];
$db=new mysqli("localhost","root","ck","newssystem");
if(mysqli_connect_error())
{
    echo "连接错误";
    }
    else
    {
        $sql="select * from news where newsid='".$id."'";
        $result=$db->query($sql);
        $row=$result->fetch_row();
    }
?>
<body>
<form action="xwxg.php" method="post">
<center><h1>修改页面</h1></center>
<div style="visibility:hidden"><span>编号</span><input type="text" name="newsid" value="<?php echo $row[0]?>"></div>
<div id="a"><h3>标题:</h3></div>
<div id="aa"><input type="text" name="title" style="width:300px" value="<?php echo $row[1]?>" /></div>
<div id="b"><h3>作者:</h3></div>
<div id="bb"><input type="text" name="author" width="80px" value="<?php echo $row[2]?>"/></div>
<div id="c"><h3>来源:</h3></div>
<div id="cc"><input type="text" name="source"  width="80px" value="<?php echo $row[3]?>"/></div>
<div id="d"><h3>内容:</h3></div>
<div id="dd"><textarea name="content" cols="50" rows="10" style="resize:none" value="<?php echo $row[4]?>"></textarea>
</div>
<div style="visibility:hidden"><span>时间</span><input type="text" name="time" value="<?php echo $row[5]?>"></div>
<div id="f"><input type="submit" name="tijia" value="修改"/></div>
<div id="ff"><a href="xwck.php"><input type="button" name="chakan" value="查看"/></a></div>
</form>
</body>
</html>
xwxg
<!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>
<?php
$newid=$_POST["newsid"];    
$title=$_POST["title"];
$author=$_POST["author"];
$source=$_POST["source"];
$content=$_POST["content"];

$db= new mysqli("localhost","root","ck","newssystem");
$date = date("Y-m-d H:i:s");
if(mysqli_connect_error())
{
    echo "连接错误";
    }
else
{
    $sql="update news set title='".$title."',author='".$author."',source='".$source."',content='".$content."',time='".$date."' where newsid='".$newid."'";
    $result=$db->query($sql);
    
    if($result)
    {
        header("Location:xwzy.php");
        }
        else 
        
        {
        echo "修改失败";}
    }
?>
</body>
</html>
xwxgzy

 

posted on 2016-02-17 15:51  让心开始  阅读(172)  评论(0编辑  收藏  举报