• 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 help me with php top frags

Baiakym

New Member
Joined
Aug 28, 2015
Messages
15
Reaction score
2
Hello, I am trying to make a change on my website, in the right corner appears the top 10 lvl and top 10 guilds but I wanted it to look the top 10 fraggers instead of guilds, anyone can edit the code for me? : \

only edit top level code for the top guild with the frag rank instead of level, I've tried all ways but all times without success -.-
<div class="clean_5"></div>
<center>
<FORM ACTION="?subtopic=characters" METHOD=post>
<INPUT NAME="name" VALUE="" class="search" SIZE=20 MAXLENGTH=29>
<div class="clean_5"></div>
<INPUT TYPE=image NAME="Submit" SRC="layouts/cyber/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18>
</FORM>
</center>

<div class="clean_5"></div>

<div id="menu-label">
<div id="icon-toplevel"></div>
<div id="text-toplevel"></div>
</div>

<table width="95%" border="0">
<?PHP
$order = 0;
$number_of_people = 0;
$skills = $SQL->query('SELECT name,online,level,experience FROM players ORDER BY level DESC, experience DESC LIMIT 10;');
foreach($skills as $skill) {
$order++;
if(is_int($number_of_people / 2))
$bgcolor = $config['site']['darkborder'];
else
$bgcolor = $config['site']['lightborder'];
$number_of_people++;
$players_skill .= '<tr BGCOLOR="'.$bgcolor.'"><td align="center">'.$order.'.</td><td align="left"><B><a href="?subtopic=characters&name='.urlencode($skill['name']).'">'.($skill['online']>0 ? "<font color=\"green\">".$skill['name']."</font>" : "".$skill['name']."</font>").'</a></td> <td align="center"><font color="white"><em>('.$skill['level'].')</em></font></td>';
}
echo "$players_skill";
?>
</table>

<div class="clean_5"></div>

<div id="menu-label">
<div id="icon-topguilds"></div>
<div id="text-topguilds"></div>
</div>

<table width="100%" border="0">
<?PHP
$guilds = $SQL->query('SELECT `g`.`id` AS `id`, `g`.`name` AS `name`,
`g`.`logo_gfx_name` AS `logo`, COUNT(`g`.`name`) as `frags`
FROM `killers` k
LEFT JOIN `player_killers` pk ON `k`.`id` = `pk`.`kill_id`
LEFT JOIN `players` p ON `pk`.`player_id` = `p`.`id`
LEFT JOIN `guild_ranks` gr ON `p`.`rank_id` = `gr`.`id`
LEFT JOIN `guilds` g ON `gr`.`guild_id` = `g`.`id`
GROUP BY `name`
ORDER BY `frags` DESC, `name` ASC
LIMIT 0, 10;');
$i = 0;
foreach($guilds as $guild)
{
$i++;
echo '<tr BGCOLOR="'.$bgcolor.'">
<td align="center">'.$i.'. </td>
<td align="left">
<B><a href="?subtopic=guilds&action=show&guild=' . $guild['id'] . '">' . $guild['name'] . '</a></b>
</td>
<td align="center">' . $guild['frags'] . ' kills</td>
</tr>';
}
?>
</table>
</div>
</div>
 
Last edited:
I've tried thousands, always appears white page or the box is empty. This for example, is empty:


<?PHP
$i = 0;
foreach($SQL->query('SELECT `p`.`name` AS `name`, COUNT(`p`.`name`) as `frags`
FROM `killers` k
LEFT JOIN `player_killers` pk ON `k`.`id` = `pk`.`kill_id`
LEFT JOIN `players` p ON `pk`.`player_id` = `p`.`id`
WHERE `k`.`unjustified` = 1
GROUP BY `name`
ORDER BY `frags` DESC, `name` ASC
LIMIT 0,25;') as $player)
{
$i++;
$main_content .= '<tr bgcolor="' . (is_int($i / 2) ? $config['site']['lightborder'] : $config['site']['darkborder']) . '">
<td><a href="?subtopic=characters&name=' . urlencode($player['name']) . '">' . $player['name'] . '</a></td>
<td style="text-align: center;">' . $player['frags'] . '</td>
</tr>';
}

?>
 
Use code tags instead of spoilers.

PHP:
<?PHP
$i = 0;
foreach($SQL->query('SELECT `killed_by` as `name`, COUNT(`killed_by`) AS `frags` FROM `player_deaths` WHERE `is_player` = 1 GROUP BY `killed_by` ORDER BY COUNT(`killed_by`) DESC LIMIT 0, 25;') as $player) {
    $i++;
    $main_content .= '
    <tr bgcolor="' . (is_int($i / 2) ? $config['site']['lightborder'] : $config['site']['darkborder']) . '">
      <td>
        <a href="?subtopic=characters&name=' . urlencode($player['name']) . '">' . $player['name'] . '</a>
      </td>
      <td style="text-align: center;">' . $player['frags'] . '</td>
    </tr>';
}
 
Use code tags instead of spoilers.

PHP:
<?PHP
$i = 0;
foreach($SQL->query('SELECT `killed_by` as `name`, COUNT(`killed_by`) AS `frags` FROM `player_deaths` WHERE `is_player` = 1 GROUP BY `killed_by` ORDER BY COUNT(`killed_by`) DESC LIMIT 0, 25;') as $player) {
    $i++;
    $main_content .= '
    <tr bgcolor="' . (is_int($i / 2) ? $config['site']['lightborder'] : $config['site']['darkborder']) . '">
      <td>
        <a href="?subtopic=characters&name=' . urlencode($player['name']) . '">' . $player['name'] . '</a>
      </td>
      <td style="text-align: center;">' . $player['frags'] . '</td>
    </tr>';
}
Thanks for help but your code dont work.

I kept trying and finally got, as I said, it was only necessary to edit the top level of php.
PHP:
<?PHP
                    $order = 0;
                    $number_of_people = 0;
                    $frags = $SQL->query('SELECT ' . $SQL->tableName('p') . '.' . $SQL->fieldName('name') . ' AS ' . $SQL->fieldName('name') . ', COUNT(' . $SQL->tableName('p') . '.' . $SQL->fieldName('name') . ') as ' . $SQL->fieldName('frags') . ' FROM ' . $SQL->tableName('killers') . ' k LEFT JOIN ' . $SQL->tableName('player_killers') . ' pk ON ' . $SQL->tableName('k') . '.' . $SQL->fieldName('id') . ' = ' . $SQL->tableName('pk') . '.' . $SQL->fieldName('kill_id') . ' LEFT JOIN ' . $SQL->tableName('players') . ' p ON ' . $SQL->tableName('pk') . '.' . $SQL->fieldName('player_id') . ' = ' . $SQL->tableName('p') . '.' . $SQL->fieldName('id') . ' WHERE ' . $SQL->tableName('k') . '.' . $SQL->fieldName('unjustified') . ' = 1 GROUP BY ' . $SQL->fieldName('name') . ' ORDER BY ' . $SQL->fieldName('frags') . ' DESC, ' . $SQL->fieldName('name') . ' ASC LIMIT 10;');
                    foreach($frags as $frag) {
                          $order++;
                            if(is_int($number_of_people / 2))
                                $bgcolor = $config['site']['darkborder'];
                            else
                                $bgcolor = $config['site']['lightborder'];
                                $number_of_people++;
                                $players_frag .= '<tr BGCOLOR="'.$bgcolor.'"><td align="center">'.$order.'.</td><td align="left"><B><a href="?subtopic=characters&name='.urlencode($frag['name']).'">'.($frag['online']>0 ? "<font color=\"green\">".$frag['name']."</font>" : "".$frag['name']."</font>").'</a></td> <td align="center"><font color="white"><em>('.$frag['frags'].')</em></font></td>';
                        }
                    echo "$players_frag";
                ?>
 
Good that you managed to work it on your own.

Just one thing, your database must have look weird :eek:, table name P ?

Btw. the code i gave you was taken from gesior top fraggers php file. It works 100 percent - i'm even using it.
 
Good that you managed to work it on your own.

Just one thing, your database must have look weird :eek:, table name P ?

Btw. the code i gave you was taken from gesior top fraggers php file. It works 100 percent - i'm even using it.

No, in my db does not have these tables "K" "P" etc .... it's weird, I do not know how this script but the only thing I did was open another php (fraggers.php) and found this query there, tested and it worked.... I have no idea how it works: B
 
Back
Top