$row2 = mysql_fetch_array($res2);
$gost = $myrow["Gost"];
$res3 = mysql_query("SELECT NameCom,mini_img,Gorod FROM MatchRezult, Command WHERE idCom='$gost'");
$row3 = mysql_fetch_array($res3);
printf("<img src='%s'/>", $row2['mini_img']);
?>
</td>
<td width="28%" align="center" valign="bottom" class="comand"><?php echo $row2['NameCom'] ?></td>
<td width="8%" rowspan="2" align="right" valign="middle" class="schet"><?php echo $myrow['ZabMjach'] ?></td>
<td width="3%" rowspan="2" align="center" valign="middle" class="tochki">:</td>
<td width="8%" rowspan="2" align="left" valign="middle" class="schet"><?php echo $myrow['PropMjach'] ?></td>
<td width="27%" align="center" valign="bottom" class="comand"><?php echo $row3['NameCom'] ?></td>
<td width="12%" rowspan="2" align="left" valign="middle" class="gorod">
<?php
printf("<img src='%s'/>",$row3['mini_img']);
?>
</td>
</tr>
<tr>
<td align="center" valign="top" class="gorod"><?php echo $row2['Gorod'] ?></td>
<td align="center" valign="top" class="gorod"><?php echo $row3['Gorod'] ?></td>
</tr>
</table>
</p>
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="view">Судьи: <br>
<?php
$result = mysql_query("SELECT FSud, Isud,OSud, Gorod FROM Sudja,SudjiInMatch
WHERE Sudja.idSud = SudjiInMatch.idSud and
idMatch='$idMatch'", $db);
while($myrow = mysql_fetch_array($result))
{
printf("%s %s %s (%s)<br>",$myrow['FSud'],$myrow['Isud'],$myrow['OSud'], $myrow['Gorod']);
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
<!--Нижний блок-->
<?php include("blocks/footer.php");?>
</table>
</body>
</html>
table.php
<?php
include("blocks/bd.php");/* Соединяемся с БД */
if(isset($_GET['year']))
{$year = $_GET['year'];
$wyear=" and Year='$year'";}
else {$wyear='';}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Таблица</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="main_border">
<!--Шапка сайта-->
<? include("blocks/header.php");?>
<tr>
<td><table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<!--Левый блок-->
<?php include("blocks/left.php");?>
<td width="737" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr align="right" class="pod">
<?php
printf("<td>Год <select class='pod' size=1 type=text name=year onchange='location.href=this.value' >");
$result = mysql_query("SELECT Year FROM Chempionats WHERE NameChemp = 'Чемпионат России' GROUP BY Year ORDER BY Year desc", $db);
$myrow = mysql_fetch_array($result);
do {
$s='';
if($_GET['year'] == $myrow['Year'])
$s=" selected='selected'";
printf("<option value='table.php?year=%s' $s>%s",$myrow['Year'],$myrow['Year']);
}
while($myrow = mysql_fetch_array($result));
printf("</select></td>");
?>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class='tabler'>
<td width="29%" class='tabler'> </td>
<td width="21%" align="center" class='tabler'>Всего</td>
<td width="28%" align="center" class='tabler'>Дома</td>
<td width="22%" align="center" class='tabler'> В гостях </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="tabler">
<td class="tabler" width="38" align="center">М</td>
<td class="tabler" width="216" align="center">Команда</td>
<td class="tabler" width="33" align="center">И</td>
<td class="tabler" width="45" align="right">Мячи</td>
<td class="tabler" width="33" align="center">О</td>
<td class="tabler" width="40" align="center"> </td>
<td class="tabler" width="33" align="center">В</td>
<td class="tabler" width="33" align="center">Н</td>
<td class="tabler" width="33" align="center">П</td>
<td class="tabler" width="50" align="right">З - П </td>
<td class="tabler" width="40" align="center"> </td>
<td class="tabler" width="33" align="center">В</td>
<td class="tabler" width="33" align="center">Н</td>
<td class="tabler" width="33" align="center">П</td>
<td class="tabler" width="50" align="right">З - П </td>
<td class="tabler" width="5" align="right"> </td>
</tr>
<?php
$zapros="SELECT ID,NameCom, Gorod, sum(igrDoma) igr, sum(zab)-sum(prop) mjach, sum(ochki) ochki,sum(vdoma) vdoma,sum(ndoma) ndoma,sum(pdoma) pdoma,sum(vgost) vgost,sum(ngost) ngost,sum(pgost) pgost, sum(prgost) prgost, sum(zabgost) zabgost, sum(prdoma) prdoma, sum(zabdoma) zabdoma
FROM(
SELECT Command.idCom as ID, NameCom, Gorod, count(Gost) as igrDoma, PropMjach zab,ZabMjach prop,
CASE
WHEN PropMjach-ZabMjach>0
THEN '3'
WHEN PropMjach-ZabMjach=0
THEN '1'
ELSE '0'
END ochki,
CASE
WHEN PropMjach-ZabMjach>0
THEN '1'
ELSE '0'
END vgost,
CASE
WHEN PropMjach-ZabMjach=0
THEN '1'
ELSE '0'
END ngost,
CASE
WHEN PropMjach-ZabMjach<0
THEN '1'
ELSE '0'
END pgost,0 vdoma,0 ndoma,0 pdoma, PropMjach zabgost,ZabMjach prgost, 0 prdoma, 0 zabdoma
FROM Command, Chempionats, MatchRezult, Matches
WHERE NameChemp='Чемпионат России' and
Matches.idMatch=MatchRezult.idMatch and
Command.idCom=Gost and
Matches.idChemp=Chempionats.idChemp".$wyear."GROUP BY MatchRezult.idMatch
UNION ALL
SELECT Command.idCom as ID, NameCom, Gorod, count(Doma) as igrDoma, ZabMjach zab, PropMjach prop,
CASE
WHEN PropMjach-ZabMjach<0
THEN '3'
WHEN PropMjach-ZabMjach=0
THEN '1'
ELSE '0'
END ochki, 0,0,0,
CASE
WHEN PropMjach-ZabMjach<0
THEN '1'
ELSE '0'
END vgost,
CASE
WHEN PropMjach-ZabMjach=0
THEN '1'
ELSE '0'
END ngost,
CASE
WHEN PropMjach-ZabMjach>0
THEN '1'
ELSE '0'
END pgost, 0 zabgost, 0 prgost, PropMjach prdoma,ZabMjach zabdoma
FROM Command, Chempionats, MatchRezult, Matches
WHERE NameChemp='Чемпионат России' and
Matches.idMatch=MatchRezult.idMatch and
Command.idCom=Doma and
Matches.idChemp=Chempionats.idChemp".$wyear."GROUP BY MatchRezult.idMatch
) xxx
GROUP BY ID ORDER BY ochki desc";
$result = mysql_query($zapros, $db);
$i=1;
while($myrow = mysql_fetch_array($result))
{
printf(" <tr>
<td class='tabler2' align='right'>%s. </td>
<td class='tabler2' align='left'> <a href='view_command.php?id=%s' >%s</a>(%s)</td>
<td class='tabler2' align='center'> %s</td>
<td class='tabler2' align='right'> %s</td>
<td class='tabler2' align='center'> %s</td>
<td class='tabler2' align='center'> </td>
<td class='tabler2' align='center'> %s</td>
<td class='tabler2' align='center'> %s</td>
<td class='tabler2' align='center'> %s</td>
<td class='tabler2' align='right'> %s - %s</td>
<td class='tabler2' align='right'> </td>
<td class='tabler2' align='center'> %s</td>
<td class='tabler2' align='center'> %s</td>
<td class='tabler2' align='center'> %s</td>
<td class='tabler2' align='right'> %s - %s</td>
<td class='tabler2' align='right'> </td>
</tr>",$i,$myrow['ID'],$myrow['NameCom'],$myrow['Gorod'],$myrow['igr'],$myrow['mjach'],$myrow['ochki'], $myrow['vdoma'], $myrow['ndoma'], $myrow['pdoma'], $myrow['zabdoma'], $myrow['prdoma'], $myrow['vgost'], $myrow['ngost'], $myrow['pgost'], $myrow['zabgost'], $myrow['prgost']
);
$i++;
}
?>
</table>
<p> </p></td>
</tr>
</table></td>
</tr>
<!--Нижний блок-->
<?php include("blocks/footer.php");?>
</table>
</body>
</html>
Result.php
<?php
include("blocks/bd.php");/* Соединяемся с БД */
if(isset($_GET['year']))
{$year = $_GET['year'];
$wyear=" and Year='$year'";}
else {$wyear='';}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Таблица</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="main_border">
<!--Шапка сайта-->
<? include("blocks/header.php");?>
<tr>
<td><table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<!--Левый блок-->
<?php include("blocks/left.php");?>
<td width="737" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr align="right" class="pod">
<?php
printf("<td>Год <select class='pod' size=1 type=text name=year onchange='location.href=this.value' >");
$result = mysql_query("SELECT Year FROM Chempionats WHERE NameChemp = 'Чемпионат России' GROUP BY Year ORDER BY Year desc", $db);
$myrow = mysql_fetch_array($result);
do {
$s='';
if($_GET['year'] == $myrow['Year'])
$s=" selected='selected'";
printf("<option value='result.php?year=%s' $s>%s",$myrow['Year'],$myrow['Year']);
}
while($myrow = mysql_fetch_array($result));
printf("</select></td>");
?>
</tr>
</table>
<table width="29%" border="0" cellspacing="0" cellpadding="0">
<?php
$zapros = "SELECT Command.idCom as ID, NameCom, Gorod
FROM Command, Chempionats, CommandInChemp
WHERE NameChemp='Чемпионат России' and
Command.idCom=CommandInChemp.idCom and
Chempionats.idChemp=CommandInChemp.idChemp".$wyear." GROUP BY Command.idCom";
$result = mysql_query($zapros, $db);
$i=1;
$k=1;
printf(" <tr>
<td width='25' class='tabler'> </td>
<td width='50' class='tablerrez'> команда</td>");
while ($myrow = mysql_fetch_array($result))
{
printf("<td align='center' width='25'
class='tablerrez'> %s</td>", $i);
$comarray[$i]=$myrow['ID'];
$i++;
}
printf(" </tr>");
$result = mysql_query($zapros, $db);
while($myrow = mysql_fetch_array($result))
{
$c=1;
$zapis=1;
printf(" <tr>
<td width='25' class='tablerrez'> %s</td>
<td>
<table width='140' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td class='tablerrez2'> %s</td>
</tr>
<tr>
<td class='tablerrez'> %s</td>
</tr>
</table>
</td>",$k, $myrow['NameCom'],$myrow['Gorod']);
do {
if($k==$c)
{
$c++;
}
else
{
$vgost = $myrow["ID"];
$res3 = mysql_query("SELECT Doma, ZabMjach, PropMjach FROM MatchRezult,Matches, Chempionats
WHERE Gost='$vgost' and
Matches.idMatch=MatchRezult.idMatch and
NameChemp='Чемпионат России' and
Chempionats.idChemp=Matches.idChemp".$wyear."ORDER BY Doma ");
$row3 = mysql_fetch_array($res3);
$vdoma = $row3['Doma'];
do {
$vdoma = $row3['Doma'];
if ($comarray[$c]==$vdoma)
{
$gostarray[$k][$c]=$row3['PropMjach'].":".$row3['ZabMjach'];
$zapis++;
}
else
if($k==$c)
{
$res3 = mysql_query("SELECT Doma, ZabMjach, PropMjach FROM MatchRezult,Matches, Chempionats
WHERE Gost='$vgost' and
Matches.idMatch=MatchRezult.idMatch and
NameChemp='Чемпионат России' and
Chempionats.idChemp=Matches.idChemp".$wyear."ORDER BY Doma ");
for($mas=1;$mas<$c;$mas++)