<?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'];
$channel=$_POST['channel'];
$Is_sub=$_POST['Is_sub'];

$news_query=new mysql_db();
if($cation =="add" and trim($name)!=="" and trim($channel)!=="" and trim($Is_sub)!==""){
$list_var_name="name,channel,Is_sub";
$list_var_value="'$name','$channel','$Is_sub'";
$news_query->table=$db."download_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_category.php","manager_category.php","返回继续增加分类","返回分类管理中心");
}else
if ($cation=="del" and $id!=="" ){
$news_query->table=$db."download_sub_category";  //表名
$news_query->table_mod="5"; //插入:1，修改:2，删除:3,建表,4:查询:5
$news_query->table_where="category=$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_category";;  //表名
		$news_query->table_mod="3"; //插入:1;修改:2;删除:3;建表,4;查询:5
		$news_query->table_where="Id=$id";
		$news_query->query();
		@url_jump("manager_category.php","add_category.php","返回分类管理","返回继续增加分类");
		}else
	{
		@url_error("manager_category.php","add_category.php","返回分类管理","返回继续增加分类","你所选择的分类已存在频道，请先删除频道下的分类!");
	}
}else
if($cation=="edit" and $id!=="" and trim($name)!=="" and trim($channel)!=="" and trim($Is_sub)!==""){
$news_query->update_value="name='$name',channel='$channel',Is_sub='$Is_sub'";
$news_query->table=$db."download_category";;  //表名
$news_query->table_mod="2"; 
$news_query->table_where="Id=$id";
$news_query->query();
@url_jump("manager_category.php","add_category.php","返回分类管理中心","返回继续增加分类");
}else{
		@url_error("manager_category.php","add_category.php","返回分类管理","返回继续增加分类","错误的操作!");
}
$news_query=NULL;
?>