PHP開發(fā)企業(yè)網(wǎng)站教學(xué)刪除新聞資訊
點(diǎn)選刪除跳到delnews.php 檔案
下面我們來看下這個(gè)檔案的程式碼:
<?php //刪除新聞資訊部分代碼 require_once('conn.php'); $id = $_GET['id']; $sql = "delete from news where id='$id'"; $res = mysql_query($sql); if($res){ echo "<script>alert('刪除成功');location.href='news.php';</script>"; }else{ echo "<script>alert('刪除失敗');location.href='news.php';</script>"; } ?>
連結(jié)資料庫,取得表單帶過來的參數(shù)? id?? 然後寫sql 語句進(jìn)行刪除
執(zhí)行sql 語句刪除成功,跳轉(zhuǎn)展示頁面,這樣我們可以在展示頁面進(jìn)行查看