最近因为工作原因需要使用php开发网页,所以开始学习php,在学习的过程中也遇到了很多困难,经过不断的查询百度各种学习资料,逐步的客服了这些困难和疑惑,现在我将学习过程中编写的代码分享给有需要的朋友,仅供参考。

此系统比较简单,共有20个php文件,3个文件夹(css,images,data),php文件分别为conn.php(数据库连接),index.php(首页),type.php(新闻分类页面),newscontent.php(最新新闻页面),admin_login.php(后台登录),chkadmin.php(登录判断),admin.php(后台中心),news_add.php(添加新闻),saveadd.php(添加新闻后台),news_upd.php(修改新闻),saveupdate.php(修改新闻后台),news_del.php(删除新闻),savedel.php(删除新闻后台),type_add.php(添加新闻分类),type_add_save.php(添加新闻分类后台),type_upd.php(修改新闻分类),type_upd_save.php(修改新闻分类后台),type_del.php(删除新闻分类),type_del_save.php(删除新闻分类后台),loginout(注销用户);css样式表2个style.css(前台页面样式),backstage.css(后台页面样式);images文件夹中一个banner文件,data中含有数据库导出文件。此项目源代码资源我已上传至(https://download.csdn.net/download/modern358/11074229),请自行查找下载。

1.conn.php(数据库连接)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/27
 */

$conn = mysqli_connect("localhost","root","","news");

@ mysqli_set_charset($conn,utf8);
@ mysqli_query($conn,utf8);

if(mysqli_connect_errno($conn))
{
    echo "数据库连接MySql连接失败".mysqli_connect_error()."<br>";
}

?>

2.index.php(首页)

<?php
    require_once('conn.php');
    $key_word = @ $_POST['key_word'];
?>
<html>
<head>
    <title>新闻管理系统</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
    <div class="container">
        <div class="top_navigation">
            <span>PHP新闻管理系统</span>
            <ul>
                <li><a href="index.php">系统首页</a></li>
                <li><a href="newscontent.php">最新新闻</a></li>
                <li><a href="type.php">新闻分类</a></li>
                <li><a href="admin_login.php">后台管理</a></li>
            </ul>
        </div>
        <div class="top_banner">
            <img src="images/banner3.jpg" alt="banner">
        </div>
        <div class="content">
            <div class="content_left">
                <div class="news_type">
                    <p>新闻分类:</p>
                    <?php
                        /**
                         * Created by PhpStorm.
                         * User: jiawei
                         * Date: 2019/3/26
                         */

                        $sql2 = mysqli_query($conn,"SELECT * FROM newstype ORDER BY type_id ASC");
                        while ($info2 = mysqli_fetch_array($sql2))
                        {
                            $type_id = $info2['type_id'];
                            $type_name = $info2['type_name'];
                            echo "<span><a href='type.php?type_id=$type_id'>[$type_name]</a></span>";
                        }
                    ?>
                </div>
            </div>
            <div class="content_right">
                <form name="form1" method="post" action="index.php">
                    <span>查询主题:<input type="text" name="key_word" id="key_word" value="">
                    <input type="submit" name="news_query" id="news_query" value="查 询"></span>
                </form>

                <table class="news_list1">
                    <caption>最新新闻:</caption>
                    <tr>
                        <th class="tb_title">主 题</th>
                        <th class="tb_date">加入时间</th>
                        <th class="tb_detail">详细内容</th>
                    </tr>
                    <?php
                    $sql1 = mysqli_query($conn,"SELECT COUNT(*) AS total FROM news
                      WHERE news_title LIKE '%$key_word%'");
                    $info1 = mysqli_fetch_array($sql1);
                    $total = $info1['total'];
                    if($total == 0)
                    {
                        echo "本系统暂无任何查询数据。";
                        exit;
                    }
                    else
                    {
                        $page_size = 10;
                        if($total <= $page_size)
                        {
                            $page_connt = 1;
                        }
                        if(($total % $page_size) != 0)
                        {
                            $page_connt = intval($total/$page_size) + 1;
                        }
                        else
                        {
                            $page_connt = intval($total/$page_size);
                        }
                        if((@ $_GET['page']) == "")
                        {
                            $page = 1;
                        }
                        else
                        {
                            $page = intval($_GET['page']);
                        }
                        $sql1 = mysqli_query($conn,"SELECT * FROM news WHERE news_title LIKE '%$key_word%' 
                          ORDER BY news_id ASC LIMIT "
                            .(($page-1)*$page_size).",$page_size");
                        while($info1 = mysqli_fetch_array($sql1))
                        {
                            $news_id = $info1['news_id'];
                            $news_title = $info1['news_title'];
                            $news_date = $info1['news_date'];
                            echo "<tr>";
                            echo "<td class='tb_l'>$news_title</td>";
                            echo "<td class='tb_c'>$news_date</td>";
                            echo "<td class='tb_c'><a href='newscontent.php?news_id=$news_id' title='$news_title'>查看</a></td>";
                            echo "</tr>";
                        }
                    }
                    ?>
                </table>
                <table class="page_list1">
                    <?php
                    echo "<tr>";
                    echo "<td>共有数据&nbsp;$total&nbsp;条,每页显示&nbsp;$page_size&nbsp;条; 第&nbsp;$page&nbsp;页/共&nbsp;$page_connt&nbsp;页:&nbsp;";
                    if($page >= 2)
                    {
                        echo "<a href='index.php?page=1' title='首页'>&nbsp;首&nbsp;&nbsp;页&nbsp;</a>/<a href='index.php?page="
                        .($page-1)."' title='前一页'>前一页</a>&nbsp;&nbsp;";
                    }
                    if($page_connt >= 2)
                    {
                        for($i=1; $i<=$page_connt; $i++)
                        {
                            echo "<a href='index.php?page=$i'>&nbsp;$i&nbsp;</a>";
                        }
                    }
                    if($page >= 2)
                    {
                        echo "<a href='index.php?page=".(($page+1)>=$page_connt?$page_connt:($page+1)).
                            "' title='后一页'>&nbsp;&nbsp;后一页</a>/<a href='index.php?page=$page_connt' title='尾页'>尾页</a>";
                    }
                    echo "</td>";
                    echo "</tr>";
                    ?>

                </table>

            </div>
        </div>
        <div class="footer">
            <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
        </div>
    </div>
</body>
</html>

3.type.php(新闻分类页面)

<?php
require_once('conn.php');
?>
<html>
<head>
    <title>新闻分类</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
    <div class="top_navigation">
        <span>PHP新闻管理系统</span>
        <ul>
            <li><a href="index.php">系统首页</a></li>
            <li><a href="newscontent.php">最新新闻</a></li>
            <li><a href="type.php">新闻分类</a></li>
            <li><a href="admin_login.php">后台管理</a></li>
        </ul>
    </div>
    <div class="top_banner">
        <img src="images/banner3.jpg" alt="banner">
    </div>
    <div class="content">
        <div class="content_type">
            <table class="type_list1">
                <caption>分类新闻:</caption>
                <tr>
                    <th class="tb_title">主 题</th>
                    <th class="tb_date">加入时间</th>
                    <th class="tb_detail">详细内容</th>
                </tr>
                <?php
                /**
                 * Created by PhpStorm.
                 * User: jiawei
                 * Date: 2019/3/26
                 */
                if(empty($_GET['type_id']))
                {
                    $type_id = 1;
                }
                else
                {
                    $type_id = $_GET['type_id'];
                }
                $sql1 = mysqli_query($conn,"SELECT COUNT(*) AS total FROM news
                  WHERE news_type=$type_id");
                $info1 = mysqli_fetch_array($sql1);
                $total = $info1['total'];
                if($total == 0)
                {
                    echo "本系统暂无任何查询数据。";
                    exit;
                }
                else
                {
                    $page_size = 10;
                    if($total <= $page_size)
                    {
                        $page_connt = 1;
                    }
                    if(($total % $page_size) != 0)
                    {
                        $page_connt = intval($total/$page_size) + 1;
                    }
                    else
                    {
                        $page_connt = intval($total/$page_size);
                    }
                    if((@ $_GET['page']) == "")
                    {
                        $page = 1;
                    }
                    else
                    {
                        $page = intval($_GET['page']);
                    }
                    $sql1 = mysqli_query($conn,"SELECT * FROM news WHERE news_type='$type_id'  
                      ORDER BY news_id ASC LIMIT "
                        .(($page-1)*$page_size).",$page_size");
                    while($info1 = mysqli_fetch_array($sql1))
                    {
                        $news_id = $info1['news_id'];
                        $news_title = $info1['news_title'];
                        $news_date = $info1['news_date'];
                        echo "<tr>";
                        echo "<td class='tb_l'>[分类:$type_id] $news_title</td>";
                        echo "<td class='tb_c'>$news_date</td>";
                        echo "<td class='tb_c'><a href='newscontent.php?news_id=$news_id' title='$news_title'>查看</a></td>";
                        echo "</tr>";
                    }
                }
                ?>
            </table>
            <table class="page_list2">
                <?php
                echo "<tr>";
                echo "<td>共有数据&nbsp;$total&nbsp;条,每页显示&nbsp;$page_size&nbsp;条; 第&nbsp;$page&nbsp;页/共&nbsp;$page_connt&nbsp;页:&nbsp;";
                if($page >= 2)
                {
                    echo "<a href='type.php?page=1' title='首页'>&nbsp;首&nbsp;&nbsp;页&nbsp;</a>/<a href='type.php?page="
                        .($page-1)."' title='前一页'>前一页</a>&nbsp;&nbsp;";
                }
                if($page_connt >= 2)
                {
                    for($i=1; $i<=$page_connt; $i++)
                    {
                        echo "<a href='type.php?page=$i'>&nbsp;$i&nbsp;</a>";
                    }
                }
                if($page >= 2)
                {
                    echo "<a href='type.php?page=".(($page+1)>=$page_connt?$page_connt:($page+1)).
                        "' title='后一页'>&nbsp;&nbsp;后一页</a>/<a href='type.php?page=$page_connt' title='尾页'>尾页</a>";
                }
                echo "</td>";
                echo "</tr>";
                ?>

            </table>

        </div>
    </div>
    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



4.newscontent.php(最新新闻页面)

<?php
require_once('conn.php');
?>
<html>
<head>
    <title>新闻内容</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
    <div class="top_navigation">
        <span>PHP新闻管理系统</span>
        <ul>
            <li><a href="index.php">系统首页</a></li>
            <li><a href="newscontent.php">最新新闻</a></li>
            <li><a href="type.php">新闻分类</a></li>
            <li><a href="admin_login.php">后台管理</a></li>
        </ul>
    </div>
    <div class="top_banner">
        <img src="images/banner3.jpg" alt="banner">
    </div>
    <div class="news_content">
        <div>
            <table class="news_content_list">
                <?php
                /**
                 * Created by PhpStorm.
                 * User: jiawei
                 * Date: 2019/3/26
                 */
                if(empty($_GET['news_id']))
                {
                    $sql1 = mysqli_query($conn,"SELECT news_id,news_title FROM news ORDER BY news_id DESC");
                    $info1 = mysqli_fetch_array($sql1);
                    $news_id = $info1['news_id'];
                }
                else
                {
                    $news_id = $_GET['news_id'];
                }
                $sql1 = mysqli_query($conn,"SELECT * FROM news WHERE news_id=$news_id");
                $info1 = mysqli_fetch_array($sql1);
                ?>
                <tr>
                    <th class="tb_title">新闻标题:&nbsp;&nbsp;<?php echo $info1['news_title']?></th>
                    <th class="tb_date">加入时间:&nbsp;&nbsp;<?php echo $info1['news_date']?>&nbsp;&nbsp;</th>
                </tr>
                <tr>
                    <td colspan="2" style="font-weight: bold">新闻内容:</td>
                </tr>
                <tr>
                    <td colspan="2" style="text-indent: 2em;line-height: 22px;"><?php echo $info1['news_content']?></td>
                </tr>
            </table>
        </div>
    </div>
    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



5.admin_login.php(后台登录)

<html>
<head>
    <title>后台登录</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
</head>
<body class="login_bk">
    <form name="form1" method="post" action="chkadmin.php">
        <div class="login_area">
            <table>
               <tr>

                   <td colspan="2"><strong>新闻管理系统后台登录</strong></td>
               </tr>
                <tr>
                    <td class="tb_l">用户:</td>
                    <td class="tb_r"><input type="text" name="user_name" id="user_name"></td>
                </tr>
                <tr>
                    <td class="tb_l">密码:</td>
                    <td class="tb_r"><input type="password" name="pwd" id="pwd"></td>
                </tr>
                <tr>

                    <td colspan="2"><input type="submit" name="button1" id="button1" value="提 交">
                    <input type="reset" name="button2" id="button2" value="重 置"></td>
                </tr>
            </table>
            <p><a href="index.php">返回首页</a></p><sapn>提示:用户 admin, 密码123 </sapn><span>  用户 root,密码 456 </span>
        </div>
    </form>
</body>
</html>

6.chkadmin.php(登录判断)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */
require_once('conn.php');
$user_name = $_POST['user_name'];
$pwd = $_POST['pwd'];

class chkinput
{
    var $name;
    var $password;

    function __construct($n,$p)
    {
        $this->name = $n;
        $this->password = $p;
    }

    function checkinput()
    {
        include('conn.php');
        $sql = mysqli_query($conn,"SELECT * FROM admin WHERE username='".$this->name."'");
        $info = mysqli_fetch_array($sql);
        if($info == false)
        {
            echo "<script>alert('用户名输入错误!');history.back();</script>";
            exit;
        }
        else
        {
            if($info['password']==$this->password)
            {
                session_start();
                $_SESSION['user_name'] = $info['username'];
                $_SESSION['id'] = $info['id'];
                header("location:admin.php");
                exit;
            }
            else
            {
                echo "<script>alert('密码输入不正确!');history.back();</script>";
                exit;
            }
        }

    }

}

$obj = new chkinput($user_name,$pwd);
$obj->checkinput();

7.admin.php(后台中心)

<?php
session_start();
require_once('conn.php');
$key_word = @ $_POST['key_word'];
?>
<html>
<head>
    <title>系统后台</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
            if(@ $_SESSION['user_name'] == "")
            {
                echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
                exit;
            }
            else
            {
                $user_name = $_SESSION['user_name'];
                echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <div class="content_left">
            <div class="news_type">
                <table>
                    <tr>
                        <th>新闻管理系统后台中心:</th>
                    </tr>
                    <tr>
                        <td><a href="news_add.php">添加新闻</a></td>
                    </tr>
                    <tr>
                        <td><a href="type_add.php">添加新闻分类</a></td>
                    </tr>
                    <tr>
                        <td>分类/管理</td>
                    </tr>
                    <?php
                    $sql2 = mysqli_query($conn,"SELECT * FROM newstype ORDER BY type_id ASC");
                    while ($info2 = mysqli_fetch_array($sql2))
                    {
                        $type_id = $info2['type_id'];
                        $type_name = $info2['type_name'];
                        echo "<tr>";
                        echo "<td>[$type_name]&nbsp;&nbsp;<a href='type_upd.php?type_id=$type_id'>修改</a>
                        &nbsp;&nbsp;<a href='type_del.php?type_id=$type_id'>删除</a></td>";
                        echo "</tr>";
                    }
                    ?>
                </table>

            </div>
        </div>
        <div class="content_right">
            <form name="form1" method="post" action="admin.php">
                    <span>查询主题:<input type="text" name="key_word" id="key_word" value="">
                    <input type="submit" name="news_query" id="news_query" value="查 询"></span>
            </form>

            <table class="news_list1">
                <caption>新闻列表:</caption>
                <tr>
                    <th class="tb_title">标 题</th>
                    <th class="tb_date">加入时间</th>
                    <th class="tb_detail">详细内容</th>
                </tr>
                <?php
                $sql1 = mysqli_query($conn,"SELECT COUNT(*) AS total FROM news
                      WHERE news_title LIKE '%$key_word%'");
                $info1 = mysqli_fetch_array($sql1);
                $total = $info1['total'];
                if($total == 0)
                {
                    echo "本系统暂无任何查询数据。";
                    exit;
                }
                else
                {
                    $page_size = 10;
                    if($total <= $page_size)
                    {
                        $page_connt = 1;
                    }
                    if(($total % $page_size) != 0)
                    {
                        $page_connt = intval($total/$page_size) + 1;
                    }
                    else
                    {
                        $page_connt = intval($total/$page_size);
                    }
                    if((@ $_GET['page']) == "")
                    {
                        $page = 1;
                    }
                    else
                    {
                        $page = intval($_GET['page']);
                    }
                    $sql1 = mysqli_query($conn,"SELECT * FROM news WHERE news_title LIKE '%$key_word%' 
                          ORDER BY news_id ASC LIMIT "
                        .(($page-1)*$page_size).",$page_size");
                    while($info1 = mysqli_fetch_array($sql1))
                    {
                        $news_id = $info1['news_id'];
                        $news_title = $info1['news_title'];
                        $news_date = $info1['news_date'];
                        echo "<tr>";
                        echo "<td class='tb_l'>$news_title</td>";
                        echo "<td class='tb_c'>$news_date</td>";
                        echo "<td class='tb_c'><a href='news_upd.php?news_id=$news_id'>修改</a>&nbsp;&nbsp;
                            <a href='news_del.php?news_id=$news_id'>删除</a></td>";
                        echo "</tr>";
                    }
                }
                ?>
            </table>
            <table class="page_list1">
                <?php
                echo "<tr>";
                echo "<td>共有数据&nbsp;$total&nbsp;条,每页显示&nbsp;$page_size&nbsp;条; 第&nbsp;$page&nbsp;页/共&nbsp;$page_connt&nbsp;页:&nbsp;";
                if($page >= 2)
                {
                    echo "<a href='admin.php?page=1' title='首页'>&nbsp;首&nbsp;&nbsp;页&nbsp;</a>/<a href='admin.php?page="
                        .($page-1)."' title='前一页'>前一页</a>&nbsp;&nbsp;";
                }
                if($page_connt >= 2)
                {
                    for($i=1; $i<=$page_connt; $i++)
                    {
                        echo "<a href='admin.php?page=$i'>&nbsp;$i&nbsp;</a>";
                    }
                }
                if($page >= 2)
                {
                    echo "<a href='admin.php?page=".(($page+1)>=$page_connt?$page_connt:($page+1)).
                        "' title='后一页'>&nbsp;&nbsp;后一页</a>/<a href='admin.php?page=$page_connt' title='尾页'>尾页</a>";
                }
                echo "</td>";
                echo "</tr>";
                ?>

            </table>

        </div>
    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>


8.news_add.php(添加新闻)

<?php
session_start();
require_once('conn.php');

?>
<html>
<head>
    <title>添加新闻</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
    <script type="text/javascript">
        function chkinput(form)
        {
            if(form.news_title.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写新闻标题!";
                form.news_title.style.backgroundColor = "red";
                form.news_title.select();
                return false;
            }
            if(form.news_author.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写作者!";
                form.news_author.style.backgroundColor = "red";
                form.news_author.select();
                return false;
            }
            if(form.news_content.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写新闻内容!";
                form.news_content.style.backgroundColor = "red";
                form.news_content.select();
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
        if(@ $_SESSION['user_name'] == "")
        {
            echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
            exit;
        }
        else
        {
            $user_name = $_SESSION['user_name'];
            echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            echo "<span>&nbsp;&nbsp;<a href='admin.php'>后台首页</a>&nbsp;&nbsp;</span>";
        }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <form name="form1" method="post" action="saveadd.php" onsubmit="return chkinput(this)">
            <table class="newsadd_tb">
                <tr>
                    <td colspan="2"><strong>添加新闻:</strong></td>
                </tr>
                <tr>
                    <td>新闻标题:</td>
                    <td><input type="text" name="news_title" id="news_title">
                    <input type="hidden" name="news_date" id="news_date" value="<?php echo date("Y-m-d");?>"></td>
                </tr>
                <tr>
                    <td>新闻分类:</td>
                    <td><select name="news_type">
                        <?php
                            $sql = mysqli_query($conn,"SELECT * FROM newstype");
                            while($info = mysqli_fetch_array($sql))
                            {
                                $type_id = $info['type_id'];
                                $type_name = $info['type_name'];
                                echo "<option value='$type_id'>$type_name</option>";
                            }
                        ?>
                        </select>&nbsp;*&nbsp;&nbsp;作者:<input type="text" name="news_author" id="news_author"></td>
                </tr>
                <tr>
                    <td>新闻内容:</td>
                    <td><textarea name="news_content" rows="20" cols="100"></textarea></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><input type="submit" name="button1" id="button1" value="添 加">
                    <input type="reset" name="button2" id="button2"><span id="error_note">&nbsp;</span></td>

                </tr>
            </table>
        </form>

    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



9.saveadd.php(添加新闻后台)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */

include('conn.php');

$news_title = $_POST['news_title'];
$news_type = $_POST['news_type'];
$news_author = $_POST['news_author'];
$news_content = $_POST['news_content'];
$news_date = $_POST['news_date'];

mysqli_query($conn,"INSERT INTO news(news_title,news_type,news_content,news_date,news_author)
  VALUES('$news_title',$news_type,'$news_content','$news_date','$news_author')");

echo "<script>alert('添加成功!');history.go(-1);</script>";

?>

10.news_upd.php(修改新闻)

<?php
session_start();
require_once('conn.php');

?>
<html>
<head>
    <title>修改新闻</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
    <script type="text/javascript">
        function chkinput(form)
        {
            if(form.news_title.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写新闻标题!";
                form.news_title.style.backgroundColor = "red";
                form.news_title.select();
                return false;
            }
            if(form.news_author.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写作者!";
                form.news_author.style.backgroundColor = "red";
                form.news_author.select();
                return false;
            }
            if(form.news_content.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写新闻内容!";
                form.news_content.style.backgroundColor = "red";
                form.news_content.select();
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
        if(@ $_SESSION['user_name'] == "")
        {
            echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
            exit;
        }
        else
        {
            $user_name = $_SESSION['user_name'];
            echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            echo "<span>&nbsp;&nbsp;<a href='admin.php'>后台首页</a>&nbsp;&nbsp;</span>";
        }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <form name="form1" method="post" action="saveupdate.php" onsubmit="return chkinput(this)">
            <table class="newsadd_tb">
                <?php
                    $news_id = $_GET['news_id'];
                    $sql1 = mysqli_query($conn,"SELECT * FROM news WHERE news_id=$news_id");
                    $info1 = mysqli_fetch_array($sql1);

                ?>
                <tr>
                    <td colspan="2"><strong>修改新闻:</strong></td>
                </tr>
                <tr>
                    <td>新闻标题:</td>
                    <td><input type="text" name="news_title" id="news_title" value="<?php echo $info1['news_title'];?>">
                        <input type="hidden" name="news_date" id="news_date" value="<?php echo date("Y-m-d");?>">
                    <input type="hidden" name="news_id" id="news_id" value="<?php echo $info1['news_id'];?>"></td>
                </tr>
                <tr>
                    <td>新闻分类:</td>
                    <td><select name="news_type" id="news_type">
                            <?php
                            $sql = mysqli_query($conn,"SELECT * FROM newstype");
                            while($info = mysqli_fetch_array($sql))
                            {
                                $type_id = $info['type_id'];
                                $type_name = $info['type_name'];
                                echo "<option value=$type_id>$type_name</option>";
                            }
                            ?>
                        </select>&nbsp;*&nbsp;&nbsp;
                        作者:<input type="text" name="news_author" id="news_author" value="<?php echo $info1['news_author'];?>"></td>
                        <?php
                        $t_id = $info1['news_type'];
                        $t_id -= 1; // selectedIndex是从0开始的,数据库ID是从1开始的,为了匹配需减去1.
                        echo "<script>document.getElementById('news_type').selectedIndex='$t_id';</script>";
                        ?>
                </tr>
                <tr>
                    <td>新闻内容:</td>
                    <td><textarea name="news_content" rows="20" cols="100"><?php echo $info1['news_content'];?></textarea></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><input type="submit" name="button1" id="button1" value="修 改">
                        <input type="reset" name="button2" id="button2"><span id="error_note">&nbsp;</span></td>

                </tr>
            </table>
        </form>

    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



11.saveupdate.php(修改新闻后台)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */

include('conn.php');

$news_id = $_POST['news_id'];
$news_title = $_POST['news_title'];
$news_type = $_POST['news_type'];
$news_author = $_POST['news_author'];
$news_content = $_POST['news_content'];
$news_date = $_POST['news_date'];

mysqli_query($conn,"UPDATE news SET news_title='$news_title',news_type = '$news_type',news_content='$news_content',
news_date='$news_date',news_author='$news_author' WHERE news_id='$news_id'");

echo "<script>alert('修改成功!');history.go(-2);</script>";

?>

12.news_del.php(删除新闻)

<?php
session_start();
require_once('conn.php');

?>
<html>
<head>
    <title>删除新闻</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">

</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
        if(@ $_SESSION['user_name'] == "")
        {
            echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
            exit;
        }
        else
        {
            $user_name = $_SESSION['user_name'];
            echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            echo "<span>&nbsp;&nbsp;<a href='admin.php'>后台首页</a>&nbsp;&nbsp;</span>";
        }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <form name="form1" method="post" action="savedel.php">
            <table class="newsadd_tb">
                <?php
                $news_id = $_GET['news_id'];
                $sql1 = mysqli_query($conn,"SELECT * FROM news WHERE news_id=$news_id");
                $info1 = mysqli_fetch_array($sql1);

                ?>
                <tr>
                    <td colspan="2"><strong>删除新闻:您确认要删除此新闻吗?</strong></td>
                </tr>
                <tr>
                    <td>新闻标题:</td>
                    <td><input type="text" name="news_title" id="news_title" disabled="disabled" value="<?php echo $info1['news_title'];?>">
                        <input type="hidden" name="news_date" id="news_date" disabled="disabled" value="<?php echo date("Y-m-d");?>">
                        <input type="hidden" name="news_id" id="news_id" value="<?php echo $info1['news_id'];?>"></td>
                </tr>
                <tr>
                    <td>新闻分类:</td>
                    <td><select name="news_type" id="news_type" disabled="disabled">
                            <?php
                            $sql = mysqli_query($conn,"SELECT * FROM newstype");
                            while($info = mysqli_fetch_array($sql))
                            {
                                $type_id = $info['type_id'];
                                $type_name = $info['type_name'];
                                echo "<option value=$type_id>$type_name</option>";
                            }
                            ?>
                        </select>&nbsp;*&nbsp;&nbsp;
                        作者:<input type="text" name="news_author" id="news_author" disabled="disabled" value="<?php echo $info1['news_author'];?>"></td>
                    <?php
                    $t_id = $info1['news_type'];
                    $t_id -= 1; // selectedIndex是从0开始的,数据库ID是从1开始的,为了匹配需减去1.
                    echo "<script>document.getElementById('news_type').selectedIndex='$t_id';</script>";
                    ?>
                </tr>
                <tr>
                    <td>新闻内容:</td>
                    <td><textarea name="news_content" rows="20" cols="100" disabled="disabled"><?php echo $info1['news_content'];?></textarea></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><input type="submit" name="button1" id="button1" value="删 除">
                        <input type="reset" name="button2" id="button2"><span id="error_note">&nbsp;</span></td>

                </tr>
            </table>
        </form>

    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



13.savedel.php(删除新闻后台)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */

include('conn.php');

$news_id = $_POST['news_id'];
mysqli_query($conn,"DELETE FROM news WHERE news_id=$news_id");

echo "<script>alert('删除成功!');history.go(-2);</script>";

?>

14.type_add.php(添加新闻分类)

<?php
session_start();
require_once('conn.php');

?>
<html>
<head>
    <title>添加分类</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
    <script type="text/javascript">
        function chkinput(form)
        {
            if(form.type_name.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写分类名称!";
                form.type_name.style.backgroundColor = "red";
                form.type_name.select();
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
        if(@ $_SESSION['user_name'] == "")
        {
            echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
            exit;
        }
        else
        {
            $user_name = $_SESSION['user_name'];
            echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            echo "<span>&nbsp;&nbsp;<a href='admin.php'>后台首页</a>&nbsp;&nbsp;</span>";
        }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <form name="form1" method="post" action="type_add_save.php" onsubmit="return chkinput(this)">
            <table class="typeadd_tb">
                <tr>
                    <td colspan="2"><strong>添加新闻分类:</strong></td>
                </tr>
                <tr>
                    <td class="tb_l">新闻分类名称:</td>
                    <td><input type="text" name="type_name" id="type_name"></td>
                </tr>
                <tr>
                    <td class="tb_l">&nbsp;</td>
                    <td><input type="submit" name="button1" id="button1" value="添 加">
                        <input type="reset" name="button2" id="button2"><span id="error_note">&nbsp;</span></td>

                </tr>
            </table>
        </form>

    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



15.type_add_save.php(添加新闻分类后台)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */

include('conn.php');

$type_name = $_POST['type_name'];
mysqli_query($conn,"INSERT INTO newstype(type_name) VALUES('$type_name')");

echo "<script>alert('添加成功!');history.back();</script>";

?>

16.type_upd.php(修改新闻分类)

<?php
session_start();
require_once('conn.php');

?>
<html>
<head>
    <title>修改分类</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
    <script type="text/javascript">
        function chkinput(form)
        {
            if(form.type_name.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写分类名称!";
                form.type_name.style.backgroundColor = "red";
                form.type_name.select();
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
        if(@ $_SESSION['user_name'] == "")
        {
            echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
            exit;
        }
        else
        {
            $user_name = $_SESSION['user_name'];
            echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            echo "<span>&nbsp;&nbsp;<a href='admin.php'>后台首页</a>&nbsp;&nbsp;</span>";
        }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <form name="form1" method="post" action="type_upd_save.php" onsubmit="return chkinput(this)">
            <table class="typeadd_tb">
                <?php
                    $type_id = $_GET['type_id'];
                    $sql = mysqli_query($conn,"SELECT * FROM newstype WHERE type_id=$type_id");
                    $info = mysqli_fetch_array($sql);
                ?>
                <tr>
                    <td colspan="2"><strong>修改新闻分类:</strong></td>
                </tr>
                <tr>
                    <td class="tb_l">新闻分类名称:</td>
                    <td><input type="text" name="type_name" id="type_name" value="<?php echo $info['type_name'];?>">
                    <input type="hidden" name="type_id" id="type_id" value="<?php echo $info['type_id'];?>"></td>
                </tr>
                <tr>
                    <td class="tb_l">&nbsp;</td>
                    <td><input type="submit" name="button1" id="button1" value="修 改">
                        <input type="reset" name="button2" id="button2"><span id="error_note">&nbsp;</span></td>

                </tr>
            </table>
        </form>

    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



17.type_upd_save.php(修改新闻分类后台)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */

include('conn.php');

$type_id = $_POST['type_id'];
$type_name = $_POST['type_name'];

mysqli_query($conn,"UPDATE newstype SET type_name='$type_name' WHERE type_id='$type_id'");

echo "<script>alert('修改成功!');history.go(-2);</script>";

?>

18.type_del.php(删除新闻分类)

<?php
session_start();
require_once('conn.php');

?>
<html>
<head>
    <title>删除分类</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
        if(@ $_SESSION['user_name'] == "")
        {
            echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
            exit;
        }
        else
        {
            $user_name = $_SESSION['user_name'];
            echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            echo "<span>&nbsp;&nbsp;<a href='admin.php'>后台首页</a>&nbsp;&nbsp;</span>";
        }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <form name="form1" method="post" action="type_del_save.php">
            <table class="typeadd_tb">
                <?php
                $type_id = $_GET['type_id'];
                $sql = mysqli_query($conn,"SELECT * FROM newstype WHERE type_id=$type_id");
                $info = mysqli_fetch_array($sql);
                ?>
                <tr>
                    <td colspan="2"><strong>删除新闻分类:</strong></td>
                </tr>
                <tr>
                    <td class="tb_l">新闻分类名称:</td>
                    <td><input type="text" name="type_name" id="type_name" disabled="disabled" value="<?php echo $info['type_name'];?>">
                        <input type="hidden" name="type_id" id="type_id" value="<?php echo $info['type_id'];?>"></td>
                </tr>
                <tr>
                    <td class="tb_l">&nbsp;</td>
                    <td><input type="submit" name="button1" id="button1" value="删 除">
                        <input type="reset" name="button2" id="button2"><span id="error_note">&nbsp;</span></td>

                </tr>
            </table>
        </form>

    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



19.type_del_save.php(删除新闻分类后台)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */

include('conn.php');

$type_id = $_POST['type_id'];

mysqli_query($conn,"DELETE FROM newstype WHERE type_id='$type_id'");

echo "<script>alert('删除成功!');history.go(-2);</script>";
?>

20.loginout(注销用户)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/30
 */

session_start();
session_destroy();
header("location:index.php");
exit;

?>

21.style.css(前台页面样式),

html *,div
{
    margin: 0;
    padding: 0;
}

body
{
    font-size: 14px;
    background-color: #eeeeee;
}

/*----首页设置----------------------------------------------------------------------*/

.container
{
    width: 1060px;
    height: 100%;
    text-align: center;
    margin: 5px auto;
}

.container .top_navigation
{
    width: 100%;
    height: 50px;
    background-color: #e6a721;
    border-radius: 15px 0 0 0;
}

.container .top_navigation span
{
    float: left;
    display: inline-block;
    width: 300px;
    height: 48px;
    font-size: 30px;
    color: #333333;
    font-family: "楷体",Arial,"Arial Black";
    line-height: 48px;
    letter-spacing: 3px;
    text-shadow: 3px 3px 1px #999999;
    margin-right: 30px;
}

.container .top_navigation ul
{
    float: left;
    width: 730px;
    list-style: none;
}

.container .top_navigation ul li
{
    display: inline;
    float: left;
    height: 48px;
    line-height: 48px;
    width: 25%;
    font-size: 22px;

}

.container .top_navigation li a
{
    display: inline-block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    background-color: #e6a721;
    color: #333333;
    line-height: 48px;
}

.container .top_navigation li a:hover
{
    background-color: #e6c050;
    color: #ffffff;
}

.container .top_banner
{
    width: 100%;
    float: left;
    height:400px;
    overflow: hidden;
    margin-bottom: 15px;
    box-shadow: 3px 5px 8px #2d2d2d;
}

.container .top_banner img
{
    width: 100%;
    height: 100%;
    border: 1px solid #8294bd;
}

/*------首页内容--------------------------------------------------------------------------*/

.container .content
{
    width: 100%;
    height: 460px;
    float: left;
}

.container .content_left
{
    width: 260px;
    height: auto;
    float: left;
}

.container .content_left .news_type
{
    width: 100%;
    height: auto;
    text-align: left;
    padding-top: 10px;
    padding-left: 30px;
    font-size: medium;
}

.container .news_type p
{
    font-style: oblique;
    font-weight: bold;
    color: #2d2d2d;
}

.container .news_type span
{
    display: block;
    margin-left: 20px;
    margin-bottom: 8px;
    margin-top: 5px;
}

.container .news_type span a
{
    text-decoration: none;
    color: #2d2d2d;
}

/*---------首页右侧----------------------------------------------------------------------------*/
.container .content_right
{
    width: 780px;
    height: auto;
    float: right;
}

.container .content_right span
{
    font-size: 16px;
    margin-bottom: 10px;
}

.container .content_right span input[type=text]
{
    width: 200px;
    height: 28px;
    line-height: 28px;
}

.container .content_right span input[type=submit]
{
    width: 80px;
    height: 28px;
    line-height: 28px;
    border: 1px solid #237a47;
}


/*---------首页新闻列表-------------------------------------------------------------------------*/

.container .news_list1
{
    width: 700px;
    height: auto;
    color: #333333;
    margin: 10px auto;
    border: 1px solid #2d2d2d;
    border-collapse: collapse;
}

.container .news_list1 caption
{
    padding: 8px 20px;
    text-align: left;
    color: #ffffff;
    background-color: #555555;
}

.container .news_list1 th,.news_list1 td
{
    border: 1px solid #2d2d2d;
    height: 30px;

}

.container .news_list1 .tb_title
{
    width: 50%;
}

.container .news_list1 .tb_date
{
    width: 30%;
}

.container .news_list1 .tb_detail
{
    width: 20%;
}

.container .news_list1 .tb_l
{
    text-align: left;
    text-indent: 10px;
}

.container .news_list1 .tb_c
{
    text-align: center;
}

.container .page_list1
{
    width: 700px;
    height: auto;
    color: #2d2d2d;
    margin: 3px auto;
    border-bottom: 1px solid #2d2d2d;
    padding-bottom: 5px;
    border-collapse: collapse;
}

.container .page_list1 tr
{
    height: 40px;
}
/*-------首页底部----------------------------------------------------*/

.container .footer
{
    width: 100%;
    float: left;
    height: 50px;
    font-size: 16px;
    font-family: "微软雅黑";
    font-style: oblique;
    line-height: 50px;
    color: #ffffff;
    background-color: #e6a721;
}


/*------新闻分类-------------------------------------------------------------*/
.container .content_type
{
    width: 100%;
    height: 100%;
    float: left;

}

.container .type_list1
{
    width: 99%;
    text-align: center;
    margin: 0 auto;
    border-top: 1px solid black;
    border-bottom: 1px solid black;
    border-collapse: collapse;
}

.container .type_list1 caption
{
    text-align: left;
    margin-bottom: 15px;
    font-size: 18px;
    text-indent: 15px;
}

.container .type_list1 th,.type_list1 td
{
    height: 30px;
}

.container .type_list1 th
{
    border-bottom: 1px solid black;
    background-color: #555555;
}
.container .type_list1 td
{
    border-bottom: 1px dashed black;
}

.container .type_list1 .tb_title
{
    width: 60%;
}

.container .type_list1 .tb_date
{
    width: 15%;
}

.container .type_list1 .tb_detail
{
    width: 25%;
}

.container .type_list1 .tb_l
{
    text-align: left;
    text-indent: 10px;
}

.container .type_list1 .tb_c
{
    text-align: center;
}

.container .page_list2
{
    width: 99%;
    height: auto;
    color: #2d2d2d;
    margin: 10px auto;
    padding-bottom: 5px;
    border-collapse: collapse;
}

.container .page_list2 tr
{
    height: 40px;
}


/*-------新闻内容---------------------------------------------------------*/
.container .news_content
{
    width: 100%;
    height: auto;
    float: left;
    min-height: 400px;
    background-color: #ffffff;
}

.container .news_content_list
{
    width: 90%;
    height: auto;
    text-align: left;
    color: #444444;
    margin: 0 auto;
    border-left: 1px dashed #999999;
    border-right: 1px dashed #999999;
    padding: 2px 30px;

}

.container .news_content_list th
{
    height: 35px;
}

.container .news_content_list .tb_title
{
    width: 50%;
}

.container .news_content_list .tb_date
{
    width: 50%;
    text-align: right;
}

22.backstage.css(后台页面样式)

html *,div
{
    margin: 0;
    padding: 0;
}

body
{
    font-size: 14px;
    background-color: #eeeeee;
}

/*------后台登录-----------------------------------------------------------*/
.login_bk
{
    background-color: #cccccc;
}

.login_area
{
    width: 400px;
    height: 160px;
    border: 1px solid #555555;
    margin: 50px auto;
    background-color: #999999;
}

.login_area table
{
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    text-align: center;
    font-size: 16px;

}

.login_area .tb_l
{
    width: 35%;
    text-align: right;
}

.login_area .tb_r
{
    width: 75%;
    text-align: left;
}

.login_area input[type=text],.login_area input[type=password]
{
    width: 200px;
    height: 25px;
    line-height: 25px;
}

.login_area input[type=submit],.login_area input[type=reset]
{
    width: 80px;
    height: 30px;
    border: 1px solid green;
    margin-left: 10px;
}

/*--------后台管理---------------------------------------------------------------------*/
.container_bk
{
    width: 1060px;
    height: 100%;
    text-align: center;
    margin: 5px auto;
}

.container_bk .top_navigation
{
    width: 100%;
    height:30px;
    float: left;
    text-align: right;
}

.container_bk .top_banner
{
    width: 100%;
    float: left;
    height:100px;
    margin-bottom: 15px;
    background-color: #e6a721;
}

.container_bk .top_banner span
{
    font-size: 28px;
    font-weight: bold;
    line-height: 100px;
    color: #ffffff;
    font-style: oblique;
    letter-spacing: 20px;
}

/*-----------------------------------------------------------------------------------*/
.container_bk .content_bk
{
    width: 100%;
    height: 460px;
    float: left;

}

.container_bk .content_left
{
    width: 260px;
    height: auto;
    float: left;
}

.container_bk .content_left .news_type
{
    width: 100%;
    height: auto;
    text-align: left;
    font-size: medium;
}

.container_bk .news_type table
{
    width: 100%;
    height: auto;
    text-align: left;
    border-collapse: collapse;
}

.container_bk .news_type th,.container_bk .news_type td
{
    height: 28px;
    line-height: 28px;
    text-indent: 5px;
}





/*---------------------------------------------------------------------*/
.container_bk .content_right
{
    width: 780px;
    height: auto;
    float: right;
}

.container_bk .content_right span
{
    font-size: 16px;
    margin-bottom: 10px;
}

.container_bk .content_right span input[type=text]
{
    width: 200px;
    height: 28px;
    line-height: 28px;
}

.container_bk .content_right span input[type=submit]
{
    width: 80px;
    height: 28px;
    line-height: 28px;
    border: 1px solid #237a47;
}

/*------------------------------------------------------------------------------*/

.container_bk .news_list1
{
    width: 700px;
    height: auto;
    color: #333333;
    margin: 10px auto;
    border: 1px solid #2d2d2d;
    border-collapse: collapse;
}

.container_bk .news_list1 caption
{
    padding: 8px 20px;
    text-align: left;
    color: #ffffff;
    background-color: #555555;
}

.container_bk .news_list1 th,.news_list1 td
{
    border: 1px solid #2d2d2d;
    height: 30px;

}

.container_bk .news_list1 .tb_title
{
    width: 50%;
}

.container_bk .news_list1 .tb_date
{
    width: 20%;
}

.container_bk .news_list1 .tb_detail
{
    width: 30%;
}

.container_bk .news_list1 .tb_l
{
    text-align: left;
    text-indent: 10px;
}

.container_bk .news_list1 .tb_c
{
    text-align: center;
}

.container_bk .page_list1
{
    width: 700px;
    height: auto;
    color: #2d2d2d;
    margin: 3px auto;
    border-bottom: 1px solid #2d2d2d;
    padding-bottom: 5px;
    border-collapse: collapse;
}

.container_bk .page_list1 tr
{
    height: 40px;
}


/*-------------------------------------------------------------------------------*/

.container_bk .footer
{
    width: 100%;
    float: left;
    height: 50px;
    font-size: 16px;
    font-family: "微软雅黑";
    font-style: oblique;
    line-height: 50px;
    color: #ffffff;
    background-color: #e6a721;
}

/*--------添加新闻--------------------------------------------------------------------*/
.container_bk .content_bk .newsadd_tb
{
    width: 100%;
    border-collapse: collapse;
}

.container_bk .newsadd_tb td
{
    height: 35px;
    line-height: 35px;
}

.container_bk .newsadd_tb input[name=news_title]
{
    width: 450px;
    height: 28px;
}

.container_bk .newsadd_tb input[name=news_author]
{
    width: 250px;
    height: 26px;
}

.container_bk .newsadd_tb select
{
    width: 150px;
    height: 26px;
}

.container_bk .newsadd_tb input[type=submit],.container_bk .newsadd_tb input[type=reset]
{
    width: 80px;
    height: 28px;
    border: 1px solid green;
    margin-top: 10px;
    margin-right: 20px;
}

/*--------------------------------------------------------------------*/
.container_bk .content_bk .typeadd_tb
{
    width: 100%;
    border-collapse: collapse;
}

.container_bk .typeadd_tb td
{
    height: 35px;
    line-height: 35px;
}

.container_bk .typeadd_tb input[name=type_name]
{
    width: 300px;
    height: 28px;
}

.container_bk .typeadd_tb input[type=submit],.container_bk .typeadd_tb input[type=reset]
{
    width: 80px;
    height: 28px;
    border: 1px solid green;
    margin-top: 10px;
    margin-right: 20px;
}

.container_bk .typeadd_tb .tb_l
{
    width: 15%;

}

/*---------------------------------------------------------------*/

.container_bk .news_type a
{
    text-decoration: none;
    color: #2d2d2d;
}

.container_bk .news_list1 a
{
    text-decoration: none;
    color: #2d2d2d;
}

23.数据库文件

-- phpMyAdmin SQL Dump
-- version 4.8.4
-- https://www.phpmyadmin.net/
--
-- 主机: 127.0.0.1
-- 生成日期: 2019-03-30  
-- 服务器版本: 10.1.37-MariaDB
-- PHP 版本: 7.3.1

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- 数据库: `news`
--
CREATE DATABASE IF NOT EXISTS `news` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `news`;

-- --------------------------------------------------------

--
-- 表的结构 `admin`
--
-- 创建时间: 2019-03-26 09:43:13
--

CREATE TABLE `admin` (
  `id` int(11) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- 转存表中的数据 `admin`
--

INSERT INTO `admin` (`id`, `username`, `password`) VALUES
(1, 'admin', '123'),
(2, 'root', '456');

-- --------------------------------------------------------

--
-- 表的结构 `news`
--
-- 创建时间: 2019-03-26 09:39:24
--

CREATE TABLE `news` (
  `news_id` int(20) NOT NULL,
  `news_title` varchar(50) NOT NULL,
  `news_type` varchar(20) NOT NULL,
  `news_content` text,
  `news_date` date NOT NULL,
  `news_author` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- 转存表中的数据 `news`
--

INSERT INTO `news` (`news_id`, `news_title`, `news_type`, `news_content`, `news_date`, `news_author`) VALUES
(1, '新闻题目一', '1', '新闻内容一\r\n', '2019-03-27', '作者'),
(2, '新闻二', '1', '新闻内容二\r\n', '2019-03-27', '作者'),
(3, '新闻三', '1', '新闻内容三', '2019-03-27', '作者'),
(4, '新闻四', '1', '新闻内容四', '2019-03-30', '作者'),
(5, '新闻五', '1', '新闻内容五', '2019-03-27', '作者'),
(6, '新闻六', '1', '新闻内容六', '2019-03-27', '作者'),
(7, '新闻七', '1', '新闻内容七', '2019-03-27', '作者'),
(8, '新闻八', '1', '新闻内容八', '2019-03-27', '作者'),
(9, '新闻九', '1', '新闻内容九', '2019-03-29', '作者'),
(10, '新闻十', '1', '新闻内容十', '2019-03-27', '作者'),
(11, '新闻十一', '1', '新闻内容十一', '2019-03-30', '作者');

-- --------------------------------------------------------

--
-- 表的结构 `newstype`
--
-- 创建时间: 2019-03-26 09:41:25
--

CREATE TABLE `newstype` (
  `type_id` int(11) NOT NULL,
  `type_name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- 转存表中的数据 `newstype`
--

INSERT INTO `newstype` (`type_id`, `type_name`) VALUES
(1, '国内新闻'),
(2, '国际新闻');

--
-- 转储表的索引
--

--
-- 表的索引 `admin`
--
ALTER TABLE `admin`
  ADD PRIMARY KEY (`id`);

--
-- 表的索引 `news`
--
ALTER TABLE `news`
  ADD PRIMARY KEY (`news_id`);

--
-- 表的索引 `newstype`
--
ALTER TABLE `newstype`
  ADD PRIMARY KEY (`type_id`);

--
-- 在导出的表使用AUTO_INCREMENT
--

--
-- 使用表AUTO_INCREMENT `admin`
--
ALTER TABLE `admin`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- 使用表AUTO_INCREMENT `news`
--
ALTER TABLE `news`
  MODIFY `news_id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;

--
-- 使用表AUTO_INCREMENT `newstype`
--
ALTER TABLE `newstype`
  MODIFY `type_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

此数据库文件,有用的部分也就CREATE DATABASE news和CREATE TABLE admin,news,newstype以及INSERT INTO admin,news,newstype。

附带一张banner图片

Logo

快速构建 Web 应用程序

更多推荐