WEB ◆ TS Library ◆ 熱衷分享 ◆ 享受教學相長 ◆ 無形的網絡擁有熱情溫度的傳遞

3-6. 新訊系統的刪除工作

設計 news_delete.php 刪除新訊

<?php
require_once('../shared/conn_pdo.php');
 
$news_id = $_GET['news_id'];
 
try {
  $sql_str = "DELETE FROM news WHERE news_id = :news_id";
  $stmt = $conn -> prepare($sql_str);
  $stmt -> bindParam(':news_id', $news_id);
  $stmt -> execute();
 
  header('Location:./?page=news_index&w=a');
} 
catch ( PDOException $e ){
  die("Errpr!: ". $e->getMessage());
}

 

 

go TOP