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

Most powerfull guild, please read it! you can help

wizzar

New Member
Joined
Aug 21, 2009
Messages
90
Reaction score
0
So here's the thing, the script by elf to show on website the most powerfull guild is bugged as we all know.
Link: http://otland.net/f118/0-3-6-0-4-to...e-database-query-68893/index4.html#post727320

Where is the bug?
When none of the guild have frags, the guild names wont show up and the link to the guild will be wrong.

Fixing:

I add a condition IF, to check wether the guild have frags or not.

Code:
if(($guild['frags']) != "0")
{
$main_content .= ' <td style="width: 25%; text-align: center;">
<a href="?subtopic=guilds&action=show&guild='.$guild['id'].'"><img src="guilds/' . ((!empty($guild['logo']) && file_exists('guilds/' . $guild['logo'])) ? $guild['logo'] : 'default_logo.gif') . '" width="64" height="64" border="0"/><br />' . $guild['name'] . '</a><br />' . $guild['frags'] . ' kills
</td>';
}

Well, it works perfectly, but i want a lil more. With this only condition the topic "Most powerfull guild" on latest news goes a lil ugly.
semttuloils.png


So, i added a contra-condition, elseif.
Code:
elseif(($guild['frags']) == "0")
{
$main_content .= '<td "height="104"><center>Nenhuma das guilds possui frag.</center></td>';
}

This checks the frags, and if none of the guild have frag, the site goes like this:
semttuloyx.png

text means: None of the guild have frag.

So far, 100% ok.
BUT!..
When only ONE guild make a frag, then it goes like this:
semttuloco.png


As you can see, the contra-condition is still working, because there are still guild with no frags.

So, here is my request:
I need to make the contra-contidion elseif check ALL the guild, and if a single one have a frag, the condition is ignored.

Like here's an example:
Code:
if(($guild['frags']) != "0")
{
$main_content .= ' <td style="width: 25%; text-align: center;">
<a href="?subtopic=guilds&action=show&guild='.$guild['id'].'"><img src="guilds/' . ((!empty($guild['logo']) && file_exists('guilds/' . $guild['logo'])) ? $guild['logo'] : 'default_logo.gif') . '" width="64" height="64" border="0"/><br />' . $guild['name'] . '</a><br />' . $guild['frags'] . ' kills
</td>';
}

elseif([red]CONDITION THE CHECKS !!ALL!! GUILDS FRAGS[/red]) == "0")
{
$main_content .= '<td "height="104"><center>Nenhuma das guilds possui frag.</center></td>';
}

Thx, if you can help but you missed some point just ask.

Note: this will help loads of people wich servers have no guilds with frag.
 
New idea, but i got a problem:

Code:
while(($guild['frags']) == "0")
{
$main_content .= '<td "height="104"><center>Nenhuma das guilds possui frag.</center></td>';
}

$main_content .= ' <td style="width: 25%; text-align: center;">
<a href="?subtopic=guilds&action=show&guild='.$guild['id'].'"><img src="guilds/' . ((!empty($guild['logo']) && file_exists('guilds/' . $guild['logo'])) ? $guild['logo'] : 'default_logo.gif') . '" width="64" height="64" border="0"/><br />' . $guild['name'] . '</a><br />' . $guild['frags'] . ' kills
</td>';

While none of the guilds have frag, shows the message.
It look clean and funcitonal to me but when i try i get this:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 32767980 bytes) in C:\xampp\htdocs\latestnews.php
 
Whole thing
Code:
$main_content .= '<div class="NewsHeadline">
	<div class="NewsHeadlineBackground" style="background-image:url(' . $layout_name . '/images/news/newsheadline_background.gif)">
		<table border="0">
			<tr>
				<td style="text-align: center; font-weight: bold;">
					<font color="white">Most powerfull guilds</font>
				</td>
			</tr>
		</table>
	</div>
</div>
<table border="0" cellspacing="3" cellpadding="4" width="100%">
	<tr>';

foreach($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`
WHERE `k`.`unjustified` = 1 AND `k`.`final_hit` = 1
	GROUP BY `name`
	ORDER BY `frags` DESC, `name` ASC
	LIMIT 0, 4;') as $guild)
	$main_content .= '		<td style="width: 25%; text-align: center;">
			<a href="?subtopic=guilds&action=show&guild=' . $guild['id'] . '"><img src="guilds/' . ((!empty($guild['logo']) && file_exists('guilds/' . $guild['logo'])) ? $guild['logo'] : 'default_logo.gif') . '" width="64" height="64" border="0"/><br />' . $guild['name'] . '</a><br />' . $guild['frags'] . ' kills
		</td>';

$main_content .= '	</tr>
</table>';

THIS CODE IS THE ORGINAL (bugged, thats why im trying the conditions)!
 
other idea:
Code:
$isThereAnyFrags = false;
if(($guild['frags']) != "0")
{
$isThereAnyFrags = true;
$main_content .= ' <td style="width: 25%; text-align: center;">
<a href="?subtopic=guilds&action=show&guild='.$guild['id'].'"><img src="guilds/' . ((!empty($guild['logo']) && file_exists('guilds/' . $guild['logo'])) ? $guild['logo'] : 'default_logo.gif') . '" width="64" height="64" border="0"/><br />' . $guild['name'] . '</a><br />' . $guild['frags'] . ' kills
</td>';
}
elseif(($guild['frags']) == "0" && $isThereAnyFrags == false)
{
$main_content .= '<td "height="104"><center>Nenhuma das guilds possui frag.</center></td>';
}

tryed but then both condition are executed (image #3 from first post)
 
Works for me.
Archez - Test for wizzar

Using the 'whole thing' that you posted.
PHP:
<?php
$main_content .= '<div class="NewsHeadline">
	<div class="NewsHeadlineBackground" style="background-image:url(' . $layout_name . '/images/news/newsheadline_background.gif)">
		<table border="0">
			<tr>
				<td style="text-align: center; font-weight: bold;">
					<font color="white">Most powerfull guilds</font>
				</td>
			</tr>
		</table>
	</div>
</div>
<table border="0" cellspacing="3" cellpadding="4" width="100%">
	<tr>';

foreach($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`
WHERE `k`.`unjustified` = 1 AND `k`.`final_hit` = 1
	GROUP BY `name`
	ORDER BY `frags` DESC, `name` ASC
	LIMIT 0, 4;') as $guild)
	$main_content .= '		<td style="width: 25%; text-align: center;">
			<a href="?subtopic=guilds&action=show&guild=' . $guild['id'] . '"><img src="guilds/' . ((!empty($guild['logo']) && file_exists('guilds/' . $guild['logo'])) ? $guild['logo'] : 'default_logo.gif') . '" width="64" height="64" border="0"/><br />' . $guild['name'] . '</a><br />' . $guild['frags'] . ' kills
		</td>';

$main_content .= '	</tr>
</table>';
?>
 
It works, but it is buggy when NONE of the guilds have frags, remove all your guilds frags and run it, then you'll see what im talking about, thats why i need those condition keys
 
Add this, it should work.
PHP:
if($guild['frags'] == 0)
$main_content .= 'There are currently 0 frags on '.$config['site']['worlds']['0'].' guilds.';

Whole thing, if you don't know how to place the 'if'.
PHP:
<?php
$main_content .= '<div class="NewsHeadline">
	<div class="NewsHeadlineBackground" style="background-image:url(' . $layout_name . '/images/news/newsheadline_background.gif)">
		<table border="0">
			<tr>
				<td style="text-align: center; font-weight: bold;">
					<font color="white">Most powerfull guilds</font>
				</td>
			</tr>
		</table>
	</div>
</div>
<table border="0" cellspacing="3" cellpadding="4" width="100%">
	<tr>';

foreach($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`
WHERE `k`.`unjustified` = 1 AND `k`.`final_hit` = 1
	GROUP BY `name`
	ORDER BY `frags` DESC, `name` ASC
	LIMIT 0, 4;') as $guild)
if($guild['frags'] == 0)
$main_content .= 'There are currently 0 frags on '.$config['site']['worlds']['0'].' guilds.';
else {
	$main_content .= '		<td style="width: 25%; text-align: center;">
			<a href="?subtopic=guilds&action=show&guild=' . $guild['id'] . '"><img src="guilds/' . ((!empty($guild['logo']) && file_exists('guilds/' . $guild['logo'])) ? $guild['logo'] : 'default_logo.gif') . '" width="64" height="64" border="0"/><br />' . $guild['name'] . '</a><br />' . $guild['frags'] . ' kills
		</td>';
}
$main_content .= '	</tr>
</table>';
?>
 
Last edited:
Back
Top