select_db('characters');
require_once("minimanager/lang/czech.php");
require_once("minimanager/scripts/defines.php");
require_once("minimanager/scripts/id_tab.php");
echo('
');
if(!array_key_exists('order_by2', $_SESSION)) $_SESSION['order_by2'] = 'rating';
if(array_key_exists('order_by', $_GET)) $_SESSION['order_by2'] = $Database->real_escape_string($_GET['order_by']);
$order_by = $_SESSION['order_by2'];
if(!array_key_exists('dir2', $_SESSION)) $_SESSION['dir2'] = 1;
if(array_key_exists('dir', $_GET)) $_SESSION['dir2'] = $Database->real_escape_string($_GET['dir']);
$dir = $_SESSION['dir2'];
$dir = ($dir) ? 0 : 1;
$order_dir = ($dir) ? "ASC" : "DESC";
$PerPage = 20;
if(array_key_exists('page', $_GET)) $_SESSION['page2'] = $Database->real_escape_string($_GET['page']);
if(array_key_exists('page', $_SESSION)) $Page = $_SESSION['page2']; else $Page = 0;
$itemperpage = 30;
$DbResult = $Database->query("SELECT count(*) FROM arena_team");
$Row = $DbResult->fetch_array();
$all_record = $Row[0];
$query = $Database->query("SELECT arena_team.arenateamid AS atid, arena_team.name AS atname, arena_team.captainguid AS lguid, arena_team.type AS attype, (SELECT name FROM `characters` WHERE guid = lguid) AS l_name,(SELECT COUNT(*) FROM arena_team_member WHERE arenateamid = atid) AS tot_chars, rating AS atrating, games as atgames, wins as atwins FROM arena_team, arena_team_stats WHERE arena_team.arenateamid = arena_team_stats.arenateamid ORDER BY $order_by $order_dir LIMIT ".($Page * $PerPage).",".$PerPage);
echo($Database->error);
$this_page = $query->num_rows;
$output = "
Celkem týmů: $all_record";
$output .= "
".PagesList('?page=', $Page, $all_record, $PerPage)."";
echo($output);
ShowFooter();
?>