<?php


include("../include/config.php");
include_once("../include/functions/import.php");
verify_login_admin();
        
		
if($_REQUEST['update'] == "success")
{
	$message = "Channel Category Successfully Deleted";
	Stemplate::assign('message',$message);
	STemplate::display("administrator/show_message.tpl");
}

// DELETE BEGIN
if($_REQUEST[delete]=="true")
{
$CATID = htmlentities(strip_tags($_REQUEST[CATID]));
$sql="DELETE FROM categories_channels WHERE CATID='".mysql_real_escape_string($CATID)."'";
$conn->Execute($sql);
header("location: channelcategories.php?update=success");
}
// DELETE END

// SORT BEGIN
if($_REQUEST['sortby']=="name")
{
	$sort =" order by name";
}
elseif($_REQUEST['sortby']=="details")
{
	$sort =" order by details";
}
else
{
	$sort =" order by CATID";
}

if($_REQUEST['sorthow']=="desc")
{
	$sorthow ="desc";
}
else
{
	$sorthow ="asc";
}
// SORT END

$query="SELECT * FROM categories_channels $sort $sorthow";
$executequery = $conn->Execute($query);
$total = $executequery->recordcount()+0;
$categories = $executequery->getrows();

STemplate::assign('total',$total+0);
STemplate::assign('categories',$categories);

Stemplate::assign('error',$error);
STemplate::display("administrator/channelcategories.tpl");
?>