<?php
define('_IN_JOHNCMS', 1);

$headmod = 'users';
$textl = 'Klub fanatlari';
require_once ("../incfiles/core.php");
require_once ("../incfiles/head.php");
$sort = intval($_GET['sort']);
if (!$id) {
    echo functions::display_error('Ma\'lumotlar yo\'q');
    require_once ('../incfiles/end.php');
    exit;
}
$req = mysql_query("SELECT COUNT(*) FROM `fanclub_vote` WHERE `cid`='$id' AND `count`='" .
    $sort . "'");
$total = mysql_result($req, 0);

$req = mysql_query("SELECT * FROM `fanclub` WHERE `id`='$id'");
$club = mysql_fetch_assoc($req);
echo '<div class="phdr">' . ($sort != 1 ? 'Anti-' : '') .
    'Klub fanatlari &gt;&gt; <a href="titul_club.php?id=' . $id . '"><b>' . $club['name'] .
    '</b></a></div>';

$req = mysql_query("SELECT
`fanclub_vote`.*, `users`.*
FROM `fanclub_vote` 
LEFT JOIN `users` 
ON `fanclub_vote`.`user_id`=`users`.`id` 
WHERE `fanclub_vote`.`cid` = '$id' AND `fanclub_vote`.`count`='" . $sort . "' 
ORDER BY `fanclub_vote`.`id` DESC LIMIT $start, $kmess");
while ($res = mysql_fetch_assoc($req)) {
    echo ($i % 2) ? '<div class="list2">' : '<div class="list1">';
    if ($sort == 1) {
        if ($club['user'] == $res['user_id']) {
            $lider = '<span class="red"><b>Lider</b></span>';
        } else {
            $lider = '';
        }
        $who = ($rights == 9) ? '<a href="case.php?act=lider&amp;id=' . $id .
            '&amp;user=' . $res['id'] . '">[<small>Liderni tanlash</small>]</a>' : '';
    }
    echo functions::display_user($res, 0, 0, $lider);
    echo $who;
    echo '</div>';
    ++$i;
}
echo '<div class="phdr">Hammasi: ' . $total . '</div>';


        if ($total > $kmess) {
            echo '<div class="topmenu">' . functions::display_pagination('users_club.php?&amp;', $start, $total, $kmess) . '</div>' .
                 '<p><form action="users_club.php" method="get"><input type="text" name="page" size="2"/>' .
                 '<input type="submit" value="' . $lng['to_page'] . ' &gt;&gt;"/></form></p>';
        }
echo '<a href="titul_club.php?id=' . $id . '">В клуб</a>';

require_once ("../incfiles/end.php");

?>