<?php
include "../CheckUser.php";
include("../comm/db_sql.php");
include("../comm/config.php");
include("../comm/connect.php");
include("../comm/Function.php");

$id= $_GET['id'];
$cation= $_GET['action'];
$name=$_POST['name'];
$cate_record=explode("|", $_POST['category']);
$category=trim($cate_record['0']);
$channel=trim($cate_record['1']);
$news_query=new mysql_db();
if($cation =="add" and trim($name)!=="" and trim($category)!=="" and trim($channel)!==""){
$list_var_name="name,category,channel";
$list_var_value="'$name','$category','$channel'";
$news_query->table=$db."download_sub_category";;  //表名
$news_query->table_mod="1"; 
$news_query->list_var_name=$list_var_name; //变量名
$news_query->list_var_value=$list_var_value;//值
$news_query->query();
@url_jump("add_sub_category.php?channel=$channel","manager_sub_category.php","返回继续增加分类","返回分类管理中心");
}else
if ($cation=="del" and $id!==""){
$news_query->table=$db."download_info";  //表名
$news_query->table_mod="5"; //插入:1，修改:2，删除:3,建表,4:查询:5
$news_query->table_where="Cate_id=$id"; //查询条件;
$news_query->limit="0";       //开始行;
$news_query->page_size="1";
$news_query->query_object="*"; //所有集合还是指定集合, *表示所有集合，单个或多个集合用AND相连接
$news_query->order_by="Id asc";
$news_query->query();
$rows=$news_query->rows;
	if ($rows=="0"){
		$news_query->table=$db."download_sub_category";;  //表名
		$news_query->table_mod="3"; //插入:1;修改:2;删除:3;建表,4;查询:5
		$news_query->table_where="Id=$id";
		$news_query->query();
		@url_jump("manager_sub_category.php","manager_sub_category.php","","返回分类管理中心");
		}else
	{
		@url_error("manager_sub_category.php","add_sub_category.php","返回分类管理","返回继续增加分类","你所选择的分类已存在频道，请先删除频道下的分类!");
	}
}else
if($cation=="edit" and $id!=="" and trim($name)!=="" and trim($category)!=="" and trim($channel)!==""){
$news_query->update_value="name='$name',channel='$channel',category='$category'";
$news_query->table=$db."download_sub_category";;  //表名
$news_query->table_mod="2"; 
$news_query->table_where="Id=$id";
$news_query->query();
@url_jump("add_sub_category.php?channel=$channel","manager_sub_category.php","返回继续增加分类","返回分类管理中心");
}else{
		@url_error("manager_sub_category.php","add_sub_category.php","返回分类管理","返回继续增加分类","错误的操作!");
}
$news_query=NULL;
?>