亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

數(shù)據(jù)庫的增刪改查

Original 2019-04-06 11:08:40 113
abstract:<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <title>新聞后臺(tái)管理系統(tǒng)</title></head><style type="text/css">

<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <title>新聞后臺(tái)管理系統(tǒng)</title></head><style type="text/css">.wrapper {width: 1000px;margin: 20px auto;}h2 {text-align: center;}.add {margin-bottom: 20px;}.add a {text-decoration: none;color: #fff;background-color: green;padding: 6px;border-radius: 5px;}td {text-align: center;}</style><body>    <div class="wrapper">        <h2>新聞后臺(tái)管理系統(tǒng)</h2>        <div class="add">            <a href="addnews.html">增加新聞</a>        </div>        <table width="960" border="1">            <tr>                <th>ID</th>                <th>標(biāo)題</th>                <th>關(guān)鍵字</th>                <th>作者</th>                <th>發(fā)布時(shí)間</th>                <th>內(nèi)容</th>                <th>操作</th>            </tr>            <?php                // 1.導(dǎo)入配置文件                require "dbconfig.php";                // 2. 連接mysql                $link = @mysql_connect(HOST,USER,PASS) or die("提示:數(shù)據(jù)庫連接失??!");                // 選擇數(shù)據(jù)庫                mysql_select_db(DBNAME,$link);                // 編碼設(shè)置                mysql_set_charset('utf8',$link);                // 3. 從DBNAME中查詢到news數(shù)據(jù)庫,返回?cái)?shù)據(jù)庫結(jié)果集,并按照addtime降序排列                  $sql = 'select * from news order by id asc';                // 結(jié)果集                $result = mysql_query($sql,$link);                // var_dump($result);die;                // 解析結(jié)果集,$row為新聞所有數(shù)據(jù),$newsNum為新聞數(shù)目                $newsNum=mysql_num_rows($result);                  for($i=0; $i<$newsNum; $i++){                    $row = mysql_fetch_assoc($result);                    echo "<tr>";                    echo "<td>{$row['id']}</td>";                    echo "<td>{$row['title']}</td>";                    echo "<td>{$row['keywords']}</td>";                    echo "<td>{$row['autor']}</td>";                    echo "<td>{$row['addtime']}</td>";                    echo "<td>{$row['content']}</td>";                    echo "<td>                            <a href='javascript:del({$row['id']})'>刪除</a>                            <a href='editnews.php?id={$row['id']}'>修改</a>                          </td>";                    echo "</tr>";                }                // 5. 釋放結(jié)果集                mysql_free_result($result);                mysql_close($link);            ?>        </table>    </div>        <script type="text/javascript">        function del (id) {            if (confirm("確定刪除這條新聞嗎?")){                window.location = "action-del.php?id="+id;            }        }    </script></body></html>

Release Notes

Popular Entries