<?php

$oForm = new cForm();
$oFunctions = new cFunctions($this->oDb, $this->oUrl, $this->oSession, $oForm);

$ret = "";


if (isset($_SESSION) && !empty($_SESSION)){
	$query="SELECT *
			FROM `users`
			Where klub_id = ?
			ORDER BY `respekt` DESC";
	$q= $this->oDb->queryWithBids($query, array($_SESSION['klubId']));
	$co="klubu";
}else {
	$query="SELECT *
			FROM `users`
			ORDER BY `respekt` DESC";
	$q= $this->oDb->query($query);
	$co="systemu";
}

$ret .= tableHead("Ranking naseho ".$co,Array(
		"Poradie","Meno","priezvisko","Vek"
), false);

$i=1;
while ($bR = $this->oDb->get($q)) {
	$ret.= '<tr>'."\n";
	$ret .= '<td>'.$i. '</td>'."\n";
	$ret .= '<td>'.$bR['meno']. '</td>'."\n";
	$ret .= '<td>'.$bR['priezvisko']. '</td>'."\n";
	$ret .= '<td>'.$bR['vek']. '</td>'."\n";
	$ret.= '</tr>'."\n";
	$i++;
}
$ret .= '</table>'."\n";

echo $ret;

function tableHead($caption, $array, $operations = TRUE) {
	$zebraCounter = 0;
	$string = '<table cellspacing="1" cellpadding="0">'."\n";
	if (strlen($caption) > 0)
		$string .= '		<caption>'.$caption.'</caption>'."\n";
	$string .= '	<tr>'."\n";
	for ($i=0;$i<count($array);$i++)
		$string .= '		<th>'.$array[$i].'</th>'."\n";
	if ($operations)
		$string .= '		<th></th>'."\n";
	$string .= '	</tr>'."\n";
	return $string;
}




?>