Quote:
Originally Posted by Sugoi na
Hey it's better then nothing =)
I will give it a shot for now & hopefully Jaxel can work his magic!
Great job none the less!
|
After testing it out for a day on my forum i decided i made a huge mistake. I shouldn't have added the gold into the calculation. Will remove this later today.
EDIT:
This is the new code :
PHP Code:
if ($_REQUEST['do'] == 'enlist')
{
$totals = $vbulletin->db->query_first("SELECT COUNT(playerID) AS playerID, SUM(pGold) AS pGold, SUM(pTroops) AS pTroops
FROM ".TABLE_PREFIX."conquest_players AS conquest_players
");
if (!$totals['playerID']) { $totals['playerID'] = 1; }
if (!$totals['pGold']) { $totals['pGold'] = 1; }
if (!$totals['pTroops']) { $totals['pTroops'] = 1; }
$nations = $vbulletin->db->query_read("SELECT conquest_nations.*, COUNT(playerID) AS playerID, SUM(pGold) AS pGold, SUM(pTroops) AS pTroops
FROM ".TABLE_PREFIX."conquest_nations AS conquest_nations
LEFT JOIN ".TABLE_PREFIX."conquest_players AS conquest_players ON conquest_nations.nationID = conquest_players.nationID
GROUP BY conquest_nations.nationID
");
$nationsagain = $vbulletin->db->query_read("SELECT conquest_nations.*, COUNT(playerID) AS playerID, SUM(pGold) AS pGold, SUM(pTroops) AS pTroops
FROM ".TABLE_PREFIX."conquest_nations AS conquest_nations
LEFT JOIN ".TABLE_PREFIX."conquest_players AS conquest_players ON conquest_nations.nationID = conquest_players.nationID
GROUP BY conquest_nations.nationID
");
$totaleverything = array();
while($nation2 = $vbulletin->db->fetch_array($nationsagain))
{
$totaleverything[] = number_format((($nation2['playerID']) + ($nation2['pTroops'])) / ($totals['playerID'] + $totals['pTroops']) * 100, 2);
}
$id = 0;
while ($nation = $vbulletin->db->fetch_array($nations))
{
if(!($totaleverything[$id] >= 33))
{
if (file_exists($thumbdir.'/nations/'.$nation['nationID'].'.jpg')) { $imageE = true; } else { $imageE = false; }
$nation['AVGplayerID'] = number_format($nation['playerID'] / $totals['playerID'] * 100, 2);
$nation['AVGpGold'] = number_format($nation['pGold'] / $totals['pGold'] * 100, 2);
$nation['AVGpTroops'] = number_format($nation['pTroops'] / $totals['pTroops'] * 100, 2);
eval('$nationsHTML .= "' . fetch_template('conquest_enlist_bit') . '";');
}
$id ++;
}
$pageNAME = $vbphrase['conquest_enlist'];
eval('$conquestHTML .= "' . fetch_template('conquest_enlist') . '";');
$navbits[] = $pageNAME;
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('conquest_SHELL') . '");');
}
Will edit this in previous post too.