zoukankan      html  css  js  c++  java
  • 《新闻发布》解析

    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="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="240px; height:20px; margin-left:10px" /></div>
            <div style="margin-top:10px">作者:<input name="author" type="text" style="150px; height:20px; margin-left:10px" /></div>
            <div style="margin-top:10px">来源:<input name="source" type="text" style="150px; height:20px; margin-left:10px" /></div>
            <div style="margin-top:10px">内容:<input name="content" type="textarea" style="420px; height:120px; margin-left:10px" /></div>
    
        <div style="float:left; margin-left:200px"><input type="submit" value="提交" style="50px; height:30px; margin-top:10px" /></div>
    
    <form action="newsmain.php">
        <div style="float:left"><input type="submit" value="查看" style="margin-top:10px; 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="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="240px; height:20px; margin-left:10px" /></div>
            <div style="margin-top:10px">作者:<input value="<?php echo $a[2] ?>" name="author" type="text" style="150px; height:20px; margin-left:10px" /></div>
            <div style="margin-top:10px">来源:<input value="<?php echo $a[3] ?>" name="source" type="text" style="150px; height:20px; margin-left:10px" /></div>
            <div style="margin-top:10px">内容:<input value="<?php echo $a[4] ?>" name="content" type="textarea" style="420px; height:120px; margin-left:10px" /></div>
    
        <div style="float:left; margin-left:200px"><input type="submit" value="修改" style="50px; height:30px; margin-top:10px" /></div>
    
    <form action="newsmain.php">
        <div style="float:left"><input type="submit" value="查看" style="margin-top:10px; 50px; height:30px; margin-left:10px" /></div>
    </form>
    </div>
    </form>
    </body>
    </html>
  • 相关阅读:
    课后作业-阅读任务-阅读笔记-4
    《团队--学生成绩管理-阶段互评》
    《团队-学生成绩管理-阶段互评》
    团队编程项目作业4-开发文档
    阅读任务--阅读提问-3
    课后作业-阅读任务-阅读笔记3
    课后作业-阅读任务-阅读提问-3
    课后作业-阅读任务-阅读笔记-3
    结对编程项目作业5
    结对编程项目作业4
  • 原文地址:https://www.cnblogs.com/sq45711478/p/6034438.html
Copyright © 2011-2022 走看看