• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved PHP - "rank data"

ATT3

Intermediate OT User
Joined
Sep 22, 2010
Messages
512
Reaction score
100
I can't figure it out myself, so;

I am trying to not to repeat ranks on every character.
So not like this;
qOcY48Y.png


Instead something like this;
MScQY3p.png


So the ranks are in "groups" or however you wanna call it.

Currently the code looks like this -> It shows rank for every player what is not my goal, it should only show 1 rank name per rank. e.g 1 time leader, 1 time vice-leader, 1 time member.
Even if there's 50 members in the guild.

Well, I guess I have made my point clear long time ago-
Code:
            if ($isOtx) {
                $rankdata = mysql_select_single("SELECT `name`,  FROM `guild_ranks` WHERE `id`='".$player['rank_id']."' LIMIT 1;");
                $player['rank_name'] = $rankdata['name'];
            }
            echo '<td>'. $player['rank_name'] .'</td>';

Could somebody assist me a bit with this?


----
Rank name is changeable -
Ranks are in three gategories = 'names' as 1,2 and 3
 
Last edited:
Post more of the code.
Code:
 <div class="panel-body">
<div id="guildTitleDiv">
    <?php if ($config['use_guild_logos']): ?>
    <div id="guildImageDiv" style="margin-left:510px;">
        <img style="max-width: 100px; max-height: 100px;" src="<?php logo_exists(sanitize($_GET['name'])); ?>"></img>
    </div>
    <?php endif; ?>
    <div id="guildDescription">
        <h3>Guild: <?php echo sanitize($_GET['name']); ?></h3>
    </div>
</div>
<table id="guildViewTable" class="table table-striped">
    <tr class="yellow">
        <th width="100px">Rank:</th>
        <th>Name:</th>
        <th></th>
    </tr>
  
        <?php
        if ($config['TFSVersion'] == 'TFS_10') {
            $onlinelist = array();
            $gplayers = array();
            foreach ($players as $player) {
                $gplayers[] = $player['id'];
            }
            $gplayers = join(',',$gplayers);
            $onlinequery = mysql_select_multi("SELECT `player_id` FROM `players_online` WHERE `player_id` IN ($gplayers);");
            if ($onlinequery !== false) foreach ($onlinequery as $online) {
                $onlinelist[] = $online['player_id'];
            }
        }

        foreach ($players as $player) {
            if ($config['TFSVersion'] !== 'TFS_10') {
                if ($isOtx) {
                    $chardata = mysql_select_single("SELECT `online` FROM `players` WHERE `name`='".$player['name']."' LIMIT 1;");
                } else $chardata = user_character_data($player['id'], 'online');
            } else $chardata['online'] = (in_array($player['id'], $onlinelist)) ? 1 : 0;
            echo '<tr>';
            if ($isOtx) {
                $rankdata = mysql_select_single("SELECT `name`,  FROM `guild_ranks` WHERE `id`='".$player['rank_id']."' LIMIT 1;");
                $player['rank_name'] = $rankdata['name'];
            }
            echo '<td>'. $player['rank_name'] .'</td>';
            echo '<td><a href="characterprofile.php?name='. $player['name'] .'">'. $player['name'] .'</a>';
            if ($chardata['online'] == 1) echo '<td width="400px"> <p class="pull-right"><span class="label label-success">Online</span>  <span class="label label-primary">'. $player['level'] .' '. $config['vocations'][$player['vocation']] .'</span></p> </td>';
            else
            echo '<td width="400px"> <p class="pull-right"><span class="label label-primary">'. $player['level'] .' '. $config['vocations'][$player['vocation']] .'</span></p></td>';
            echo '</tr></div></div>';
        }
        ?>
</table>
</div>

If you need more than that, rest info should be here;
https://github.com/Znote/ZnoteAAC/blob/master/guilds.php

I thought some kind of for loop would have been enough, but then again I don't know how to fix this
 
Test this
PHP:
 <div class="panel-body">
<div id="guildTitleDiv">
    <?php if ($config['use_guild_logos']): ?>
    <div id="guildImageDiv" style="margin-left:510px;">
        <img style="max-width: 100px; max-height: 100px;" src="<?php logo_exists(sanitize($_GET['name'])); ?>"></img>
    </div>
    <?php endif; ?>
    <div id="guildDescription">
        <h3>Guild: <?php echo sanitize($_GET['name']); ?></h3>
    </div>
</div>
<table id="guildViewTable" class="table table-striped">
    <tr class="yellow">
        <th width="100px">Rank:</th>
        <th>Name:</th>
        <th></th>
    </tr>

        <?php
        if ($config['TFSVersion'] == 'TFS_10') {
            $onlinelist = array();
            $gplayers = array();
            foreach ($players as $player) {
                $gplayers[] = $player['id'];
            }
            $gplayers = join(',',$gplayers);
            $onlinequery = mysql_select_multi("SELECT `player_id` FROM `players_online` WHERE `player_id` IN ($gplayers);");
            if ($onlinequery !== false) foreach ($onlinequery as $online) {
                $onlinelist[] = $online['player_id'];
            }
        }

        $last_rank_name = '';
        foreach ($players as $player) {
            if ($config['TFSVersion'] !== 'TFS_10') {
                if ($isOtx) {
                    $chardata = mysql_select_single("SELECT `online` FROM `players` WHERE `name`='".$player['name']."' LIMIT 1;");
                } else $chardata = user_character_data($player['id'], 'online');
            } else $chardata['online'] = (in_array($player['id'], $onlinelist)) ? 1 : 0;
            echo '<tr>';
            if ($isOtx) {
                $rankdata = mysql_select_single("SELECT `name`,  FROM `guild_ranks` WHERE `id`='".$player['rank_id']."' LIMIT 1;");
                $player['rank_name'] = $rankdata['name'];
            }
            echo '<td>'. ($last_rank_name == $player['rank_name'] ? '' : $player['rank_name']) .'</td>';
            $last_rank_name = $player['rank_name'];
            echo '<td><a href="characterprofile.php?name='. $player['name'] .'">'. $player['name'] .'</a>';
            if ($chardata['online'] == 1) echo '<td width="400px"> <p class="pull-right"><span class="label label-success">Online</span>  <span class="label label-primary">'. $player['level'] .' '. $config['vocations'][$player['vocation']] .'</span></p> </td>';
            else
            echo '<td width="400px"> <p class="pull-right"><span class="label label-primary">'. $player['level'] .' '. $config['vocations'][$player['vocation']] .'</span></p></td>';
            echo '</tr></div></div>';
        }
        ?>
</table>
</div>
 
Back
Top