Changeset 29 for trunk/index.php


Ignore:
Timestamp:
Sep 17, 2019, 10:58:51 PM (5 years ago)
Author:
chronos
Message:
  • Added: Show links to previous years for individual runners and teams.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r28 r29  
    4747  }
    4848
    49   function YearList($Path, $SelectedYear)
     49  function YearList($Path, $SelectedYear, $Table = 'Runner', $Where = '1')
    5050  {
    5151    $Output = 'Year: ';
    52     $DbResult = $this->Database->query('SELECT DISTINCT(Year) AS Year FROM `Runner` ORDER BY Year ASC');
     52    $DbResult = $this->Database->query('SELECT DISTINCT(Year) AS Year FROM `'.$Table.'` WHERE '.$Where.' ORDER BY Year ASC');
    5353    while ($DbRow = $DbResult->fetch_assoc())
    5454    {
     
    5656      $Item = '<a href="'.$this->Link($Path.$Year.'/').'">'.$Year.'</a>';
    5757      if ($SelectedYear == $Year) $Item = '<strong>'.$Item.'</strong>';
     58      $Output .= $Item.' ';
     59    }
     60    return $Output;
     61  }
     62
     63  function ItemsYearList($Path, $SelectedId, $Table = 'Runner', $Where = '1')
     64  {
     65    $Output = 'Year: ';
     66    $DbResult = $this->Database->query('SELECT T1.Id AS Id, T2.Year AS Year FROM (SELECT DISTINCT(Id) AS Id FROM `'.$Table.'` WHERE '.$Where.' ORDER BY Year ASC) AS T1 '.
     67      'LEFT JOIN '.$Table.' AS T2 ON T1.Id=T2.Id');
     68    while ($DbRow = $DbResult->fetch_assoc())
     69    {
     70      $Item = '<a href="'.$this->Link($Path.$DbRow['Id'].'/').'">'.$DbRow['Year'].'</a>';
     71      if ($SelectedId == $DbRow['Id']) $Item = '<strong>'.$Item.'</strong>';
    5872      $Output .= $Item.' ';
    5973    }
     
    435449      $Where .= ' AND (Name LIKE "%'.addslashes($_GET['query']).'%")';
    436450    }
    437     $Output .= '<div class="section-title">'.$this->YearList('/teams/', $Year).' Name: '.$this->ShowSearch().'</div>';
     451    $Output .= '<div class="section-title">'.$this->YearList('/teams/', $Year, 'Team').' Name: '.$this->ShowSearch().'</div>';
    438452
    439453    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE '.$Where);
     
    509523    $DbRow = $DbResult->fetch_assoc();
    510524    $Output .= '<div class="page-title">Team '.$DbRow['Name'].'</div>';
     525    $Output .= '<div class="section-title">'.$this->ItemsYearList('/team/', $TeamId, 'Team', 'Name="'.$DbRow['Name'].'"').'</div>';
    511526    $Output .= '<div class="section-title">Runners: '.$DbRow['RunnerCount'].', Distance: '.$DbRow['Distance'].' km, Money: '.$DbRow['Money'].' Kč, Rank: '.$DbRow['Rank'].'</div>';
    512527
     
    677692    $Year = $this->GetYear();
    678693
    679     $Output .= '<div class="section-title">'.$this->YearList('/runners/', $Year).' Name: '.$this->ShowSearch().'</div>';
     694    $Output .= '<div class="section-title">'.$this->YearList('/runners/', $Year, 'Runner').' Name: '.$this->ShowSearch().'</div>';
    680695    $Where = '(Year='.$Year.')';
    681696    if (array_key_exists('query', $_GET) and ($_GET['query'] != ''))
     
    741756    if ($DbRow['TeamName'] != '')
    742757      $Output .= '<div class="section-title"><a href="'.$this->Link('/team/'.$DbRow['TeamId']).'">'.$DbRow['TeamName'].'</a></div>';
     758    $Output .= '<div class="section-title">'.$this->ItemsYearList('/runner/', $RunnerId, 'Runner', 'Name="'.$DbRow['Name'].'"').'</div>';
    743759
    744760    $Output .= $this->ShowDetailed('Runner', $RunnerId);
Note: See TracChangeset for help on using the changeset viewer.