Changeset 104


Ignore:
Timestamp:
Oct 7, 2007, 1:15:56 PM (17 years ago)
Author:
george
Message:

Přidáno: Možnost řazení obsahu tabulky podle jednotlivých sloupců.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guildy.php

    r28 r104  
    99$RanksCZ = array('Pán cechu', 'Veterán', 'Vrchní správce', 'Pomocný dùstojník', 'PR dùstojník', 'Dùstojník', 'Proslavený èlen', 'Èlen', 'Zelenáè', 'Nováèek');
    1010
     11$order_by = (isset($_GET['order_by'])) ? $Database->real_escape_string($_GET['order_by']) : "name";
     12
     13$dir = (isset($_GET['dir'])) ? $Database->real_escape_string($_GET['dir']) : 1;
     14$order_dir = ($dir) ? "ASC" : "DESC";
     15$dir = ($dir) ? 0 : 1;
     16       
     17function HeaderText($Text, $Column)
     18{
     19  global $dir, $order_by, $GuildId;
     20  echo('<th><a href="?order_by='.$Column.'&amp;dir='.$dir.'">'.($order_by==$Column ? '<img src="images/online_player/arr_'.($dir ? 'up' : 'dw').'.gif" /> ' : '').$Text.'</a></th>');
     21}
     22       
     23function HeaderTextGuild($Text, $Column)
     24{
     25  global $dir, $order_by, $GuildId;
     26  echo('<th><a href="?guild='.$GuildId.'&amp;order_by='.$Column.'&amp;dir='.$dir.'">'.($order_by==$Column ? '<img src="images/online_player/arr_'.($dir ? 'up' : 'dw').'.gif" /> ' : '').$Text.'</a></th>');
     27}
     28
    1129$Database->select_db('mangos');
    1230if(!array_key_exists('guild', $_GET))
    1331{
    1432  echo('<h3>Seznam guild:</h3><div align="center">');
    15   echo('<table class="TableGuilda" border="1" cellpadding="3" cellspacing="0"><tr><th>Název</th><th>Poèet èlenù</th><th>Souèet levelù</th><th>Souèet bodù cti</th><th>Webové stránky</th></tr>');
     33  echo('<table class="TableGuilda" border="1" cellpadding="3" cellspacing="0"><tr>');
     34  HeaderText('Název', 'name');
     35  HeaderText('Poèet èlenù', 'member_count');
     36  HeaderText('Souèet levelù', 'guild_level');
     37  HeaderText('Souèet bodù cti', 'guild_honor');
     38  HeaderText('Webové stránky', 'name');   
     39  echo('</tr>');
    1640//  DB_Query(' COUNT(guild_member.guildid) as member_count FROM guild JOIN guild_member ON guild_member.guildid = guild.guildid GROUP BY guild.name ORDER BY member_count DESC');
    17   $Result = $Database->query('SELECT `guild`.name, guild.guildid, COUNT(`guild_member`.`guildid`) as member_count, SUM(SUBSTRING_INDEX(SUBSTRING_INDEX(`character`.`data`, " ", 35), " ", -1)) as guild_level, SUM(SUBSTRING_INDEX(SUBSTRING_INDEX(`character`.`data`, " ", 1421), " ", -1)) as guild_honor FROM `guild` JOIN `guild_member` ON `guild_member`.`guildid` = `guild`.`guildid` JOIN `character` ON `character`.`guid`= `guild_member`.`guid` GROUP BY guild.name ORDER BY guild.name');
     41  $Result = $Database->query('SELECT `guild`.name, guild.guildid, COUNT(`guild_member`.`guildid`) as member_count, SUM(SUBSTRING_INDEX(SUBSTRING_INDEX(`character`.`data`, " ", 35), " ", -1)) as guild_level, SUM(SUBSTRING_INDEX(SUBSTRING_INDEX(`character`.`data`, " ", 1421), " ", -1)) as guild_honor FROM `guild` JOIN `guild_member` ON `guild_member`.`guildid` = `guild`.`guildid` JOIN `character` ON `character`.`guid`= `guild_member`.`guid` GROUP BY guild.name ORDER BY '.$order_by.' '.$order_dir);
    1842  while($Guild = $Result->fetch_array())
    1943  {
     
    2246  echo('</table></div>');
    2347} else {
    24   $_GET['guild'] = addslashes($_GET['guild']);
    25   $Result = $Database->query('SELECT `guild`.name, guild.guildid, guild.leaderguid, COUNT(`guild_member`.`guildid`) as member_count, SUM(SUBSTRING_INDEX(SUBSTRING_INDEX(`character`.`data`, " ", 35), " ", -1)) as guild_level, SUM(SUBSTRING_INDEX(SUBSTRING_INDEX(`character`.`data`, " ", 1421), " ", -1)) as guild_honor FROM `guild` JOIN `guild_member` ON `guild_member`.`guildid` = `guild`.`guildid` JOIN `character` ON `character`.`guid`= `guild_member`.`guid` WHERE guild.guildid='.$_GET['guild'].' GROUP BY guild.name');
     48  $GuildId = addslashes($_GET['guild']);
     49  $Result = $Database->query('SELECT `guild`.name, guild.guildid, guild.leaderguid, COUNT(`guild_member`.`guildid`) as member_count, SUM(SUBSTRING_INDEX(SUBSTRING_INDEX(`character`.`data`, " ", 35), " ", -1)) as guild_level, SUM(SUBSTRING_INDEX(SUBSTRING_INDEX(`character`.`data`, " ", 1421), " ", -1)) as guild_honor FROM `guild` JOIN `guild_member` ON `guild_member`.`guildid` = `guild`.`guildid` JOIN `character` ON `character`.`guid`= `guild_member`.`guid` WHERE guild.guildid='.$GuildId.' GROUP BY guild.name');
    2650  if($Result->num_rows > 0)
    2751  {
     
    3458    echo('Vedoucí guildy: '.$GuildMaster['name'].'<br>');
    3559    echo('<table class="TableGuilda" border="1" cellpadding="1" cellspacing="0">');
    36     echo('<tr><th>Jméno</th><th>Level</th><th>Hodnost</th><th>Body cti</th></tr>');
     60    echo('<tr>');
     61    HeaderTextGuild('Jméno', 'name');
     62    HeaderTextGuild('Úroveò', 'level');
     63    HeaderTextGuild('Hodnost', 'rank');
     64    HeaderTextGuild('Body cti', 'honor');   
     65    echo('</tr>');
    3766    //echo('<tr><td colspan="2" Class="TdGuilda">Informace: '.$Guild['public_info'].'</td></tr>');
    3867   
     
    4170    while($GuildRank = $Result->fetch_array()) $GuildRanks[$GuildRank['rid']] = $GuildRank;
    4271 
    43     $Result = $Database->query('SELECT guild_member.rank, guild_member.guid, SUBSTRING_INDEX(SUBSTRING_INDEX(character.data," ", 35), " ", -1)*1 as level, SUBSTRING_INDEX(SUBSTRING_INDEX(character.data," ", 1421), " ", -1)*1 as honor, character.name FROM guild_member JOIN `character` ON guild_member.guid = character.guid AND guild_member.guildid='.$Guild['guildid'].' ORDER BY character.name');
     72    $Result = $Database->query('SELECT guild_member.rank, guild_member.guid, SUBSTRING_INDEX(SUBSTRING_INDEX(character.data," ", 35), " ", -1)*1 as level, SUBSTRING_INDEX(SUBSTRING_INDEX(character.data," ", 1421), " ", -1)*1 as honor, character.name FROM guild_member JOIN `character` ON guild_member.guid = character.guid AND guild_member.guildid='.$Guild['guildid'].' ORDER BY '.$order_by.' '.$order_dir);
    4473    while($Member = $Result->fetch_array())
    4574    {
Note: See TracChangeset for help on using the changeset viewer.