• 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!

[0.3.6-0.4] Top fragers and top guilds with one database query

Znote thanks for help but i want someone like Latestnews - Infernot

your top guild ask me for Type: select_multi (select multiple rows from database)

Unknown column 'g.logo_gfx_name' in 'field list'

- - - Updated - - -

Znote thanks for help but i want something like http://infernot.net/

your top guild ask me for Type: select_multi (select multiple rows from database)

Unknown column 'g.logo_gfx_name' in 'field list'

- - - Updated - - -

i hate i can't edit -.-
 
No prob, elf got some awesome queries there. :)

(each script is an own page, just modify it if you want to have it on your news section etc).

Top fraggers:
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';

	// Cache the results
	$cache = new Cache('engine/cache/topMurders');
	if ($cache->hasExpired()) {
		$killers = mysql_select_multi("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 AND `k`.`final_hit` = 1 GROUP BY `name` ORDER BY `frags` DESC, `name` ASC LIMIT 0,30;");
		
		$cache->setContent($killers);
		$cache->save();
	} else {
		$killers = $cache->load();
	}

if (!empty($killers) || $killers !== false) {
?>

<table id="onlinelistTable" class="table table-striped table-hover">
	<tr class="yellow">
		<th>Name:</th>
		<th>Frags:</th>
	</tr>
	<?php foreach ($killers as $killer) { ?>
	<tr>
		<td><?php echo $killer['name']; ?></td>
		<td><?php echo $killer['frags']; ?></td>
	</tr>
	<?php } ?>
</table>

<?php
} else echo '<h1>No frags yet.</h1>';
 include 'layout/overall/footer.php'; ?>

Top guilds:
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; 

    // Cache the results 
    $cache = new Cache('engine/cache/topGuilds'); 
    if ($cache->hasExpired()) { 
        $guilds = mysql_select_multi("SELECT `g`.`id` AS `id`, `g`.`name` AS `name`, 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` WHERE `k`.`unjustified` = 1 AND `k`.`final_hit` = 1 GROUP BY `name` ORDER BY `frags` DESC, `name` ASC LIMIT 0, 4;"); 
         
        $cache->setContent($guilds); 
        $cache->save(); 
    } else { 
        $guilds = $cache->load(); 
    } 

if (!empty($guilds) || $guilds !== false) { 
?> 

<table id="onlinelistTable" class="table table-striped table-hover"> 
    <tr class="yellow"> 
        <th>Name:</th> 
        <th>Frags:</th> 
    </tr> 
    <?php foreach ($guilds as $guild) { 

    $url = url("guilds.php?name=". $guild['name']);
    echo '<tr class="special" onclick="javascript:window.location.href=\'' . $url . '\'">'; ?> 
        <td><?php echo $guild['name']; ?></td>
        <td><?php echo $guild['frags']; ?></td> 
    </tr> 
    <?php } ?> 
</table> 

<?php 
} else echo '<h1>No frags yet.</h1>'; 
 include 'layout/overall/footer.php'; ?>

Updated top guilds script. Should work now.
 
Updated top guilds script. Should work now.

thanks is working, i recommend to make an own section for this and dont put the script on index.php, by adding this to leftside.php

PHP:
                                <a href='topfraggers.php'>
                    <div id='submenu_guilds' class='Submenuitem' onMouseOver='MouseOverSubmenuItem(this)' onMouseOut='MouseOutSubmenuItem(this)'>
                        <div class='LeftChain' style='background-image:url(layout/images/global/general/chain.gif);'></div>
                        <div id='ActiveSubmenuItemIcon_guilds' class='ActiveSubmenuItemIcon' style='background-image:url(layout/images/global/menu/icon-activesubmenu.gif);'></div>
                        <div id='ActiveSubmenuItemLabel_guilds' class='SubmenuitemLabel'><font color="red">Top Fraggers</font></div>
                        <div class='RightChain' style='background-image:url(layout/images/global/general/chain.gif);'></div>
                    </div>
                </a>
                                <a href='topguilds.php'>
                    <div id='submenu_guilds' class='Submenuitem' onMouseOver='MouseOverSubmenuItem(this)' onMouseOut='MouseOutSubmenuItem(this)'>
                        <div class='LeftChain' style='background-image:url(layout/images/global/general/chain.gif);'></div>
                        <div id='ActiveSubmenuItemIcon_guilds' class='ActiveSubmenuItemIcon' style='background-image:url(layout/images/global/menu/icon-activesubmenu.gif);'></div>
                        <div id='ActiveSubmenuItemLabel_guilds' class='SubmenuitemLabel'><font color="red">Top Guilds</font></div>
                        <div class='RightChain' style='background-image:url(layout/images/global/general/chain.gif);'></div>
                    </div>
                </a>
 
Back
Top