Mini Shell

Direktori : /var/www/vhosts/ccp.ac.th/ep.ccp.ac.th/admin/
Upload File :
Current File : /var/www/vhosts/ccp.ac.th/ep.ccp.ac.th/admin/del_news_home.php

<?php
include '../db/database.php';
$news_id = $_GET['id'];

 //ลบรูป
  $sql_img = "SELECT news_images FROM news WHERE news_id ='$news_id'";
    $result_img = mysqli_query($link, $sql_img);
    $img_name = mysqli_fetch_row($result_img);
    @unlink('images/' . $img_name[0]);   
      
$sql = "DELETE FROM news WHERE news_id ='$news_id'";
$result = mysqli_query($link, $sql);

if ($result) {
 header('Content-Type: application/json');
    echo json_encode(array('status' => 'success', 'message' => 'ลบข้อมูลเรียบร้อยแล้ว'));
} else {
    header('Content-Type: application/json');
    $errors = "เกิดข้อผิดพลาดในการลบ กรุณาลองใหม่ ";
    echo json_encode(array('status' => 'danger', 'message' => $errors));
}

Zerion Mini Shell 1.0