<?php


include("../include/config.php");
include_once("../include/functions/import.php");
include_once("../include/functions/admin.php");
verify_login_admin();

// SORT BEGIN
if($_REQUEST['sortby']=="description")
{
	$sort =" order by description";
}
elseif($_REQUEST['sortby']=="active")
{
	$sort =" order by active";
}
else
{
	$sort =" order by AID";
}

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

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

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

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