0byt3m1n1-V2
Path:
/
home
/
bangtoey
/
domains
/
bangtoey.go.th
/
public_html
/
news
/
[
Home
]
File: delete_category.php
<?php session_start(); if($_SESSION[user]==""){ session_destroy(); $message = "¡ÃسÒ Login ¡è."; $url = "../admin/index.php"; include("../admin/alert.php"); exit; } require_once('../admin/Connections/conndb.php'); mysql_select_db($database_conndb, $conndb); $query_rsNews1 = "SELECT * FROM news_category where cat_id= '$cat_id'"; $rsNews1 = mysql_query($query_rsNews1, $conndb) or die(mysql_error()); $row_rsNews1 = mysql_fetch_assoc($rsNews1); $query_rsNews = "SELECT * FROM news_detail where cat_id= '$cat_id'"; $rsNews = mysql_query($query_rsNews, $conndb) or die(mysql_error()); //$row_rsNews = mysql_fetch_assoc($rsNews); $totalRows_rsNews = mysql_num_rows($rsNews); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } if ((isset($_GET['cat_id'])) && ($_GET['cat_id'] != "")) { $deleteALM = sprintf("DELETE FROM news_category WHERE cat_id=%s", GetSQLValueString($_GET['cat_id'], "int")); $ResultALM = mysql_query($deleteALM, $conndb) or die(mysql_error()); if($totalRows_rsNews!=0){ // ลบไฟล์เอกสาร while($row_rsNews = mysql_fetch_object($rsNews)){ if($row_rsNews->filename!=""){ echo $row_rsNews->filename; unlink("doc_download/".$row_rsNews->filename); } if($row_rsNews->pic!=""){ echo $row_rsNews->pic; unlink("photo/".$row_rsNews->pic); } $deletePIC = sprintf("DELETE FROM news_detail WHERE cat_id=%s", GetSQLValueString($_GET['cat_id'], "int")); $ResultPIC = mysql_query($deletePIC, $conndb) or die(mysql_error()); } } // $deleteGoTo = "admin.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } echo "<meta http-equiv='refresh' content='0;URL=add_category.php?'>"; } if($conndb) { mysql_close($conndb); unset($conndb); } ?>
©
2018.