php新闻发布系统发布成功从数据库查询所有数据用表格显示出来03

来源:互联网 发布:7zip解压软件下载 编辑:程序博客网 时间:2024/05/17 06:16
当弹出发布成功对话框,点击确定按钮进入到
location.href='new_list.php'进入到new_list所执行的php代码
代码如下:
<?php/** * Created by PhpStorm. * User: Administrator * Date: 2017/3/18 * Time: 18:17 * 新闻列表页面 */header("content-type:text/html;charset=utf8");//  数据库名称$conn = mysqli_connect("localhost", "root", "root", "mynews");mysqli_set_charset($conn, 'utf8'); //设定字符集//查询语句$querySql = "select *from mynews.mynews";//执行查询操作$que = mysqli_query($conn, $querySql);//print_r($que); 多维数组?><!doctype html><html><head>    <title>新闻列表展示页面</title>    <link rel="stylesheet" href="new_list.css">    <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">    <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js"></script>    <script src="http://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script></head><body><div id="body" class="body container">    <div class="row">        <div class="col-md-2"></div>        <div class="col-md-8 divTable">                <table class="table-striped" border="2" cellspacing="0">                    <thead><h3>新闻内容展示页面</h3></thead>                    <div><a href="new.html">返回发布新闻</a></div>                    <tr>                        <th>编号</th>                        <th>标题</th>                        <th>内容</th>                        <th>编辑文章</th>                        <th>发布时间</th>                    </tr>                    <!--因为这里要动态显示 要有for循环 所以要嵌入语言,可以是php也可以是js-->                    <?php                    $row = mysqli_fetch_array($que);                    // $row=mysqli_fetch_row($que);                    //print_r($row);                    while ($row = mysqli_fetch_array($que)) {                        ?>                        <tr>                            <td><?php echo $row['_id'] ?></td>                            <td><?php echo $row ['title'] ?></td>                            <td><?php echo $row['content'] ?></td>                            <td>                                <a href="new_ed.php?id=<?php echo $row['_id'] ?>">修改</a>                                <a href="new_del.php?id=<?php echo $row['_id'] ?>">删除</a>                            </td>                            <td><?php echo $row['3'] ?></td>                        </tr>                        <?php                    }                    ?>                </table>        </div>        <!-- 一行6列的结束标记-->        <div class="col-md-2"></div>    </div>    <!-- 一行的结束标记--></div></body></html>

//new_list.css代码如下
.body{    background-color: rgba(128, 128, 128, 0.3);    border: 1px solid #0000cc;}.divTable {    width: 300px;    border:2px  solid darkslateblue;    margin: 5px auto;    text-align: center;}

//运行效果如下
0 0
原创粉丝点击