<html>
<head>
<title>Rangliste Foros</title>
<link rel="stylesheet" type="text/css" href="layout.css">
</head>
<body>

<?php


$DBName="DB127817";
$TabelName="Fragen";

$Link=mysql_connect("rdbms.strato.de","U127817","ZH67uH95");


$Query="Select Mitspieler,sum(Punkte) as Punkte,count(Heimteam) as Spiele from Tippspiel1011 where Spieltag<39 group by Mitspieler";
$Result=mysql_db_query("DB127817",$Query,$Link);

echo "<table><td>";

print("<div class=text>Gesamtstand nach 38 Spieltagen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>(In Klammern getippte Spiele)<br><br></div>");

while($Row=mysql_fetch_array($Result))
{
$Gesamt[] = array('Mitspieler' => $Row[Mitspieler], 'Punkte' => $Row[Punkte], 'Spiele' => $Row[Spiele]);
       }

foreach ($Gesamt as $key => $row) {
    $Punkte[$key]  = $row['Punkte'];
    $Mitspieler[$key] = $row['Mitspieler'];
    $Spiele[$key] = $row['Spiele'];
}
array_multisort($Punkte, SORT_DESC, $Mitspieler, SORT_ASC, $Gesamt);

echo "<table>";
foreach($Gesamt as $Ausgabe){
  echo "<tr><td width=25pxl><div class=text>",$Ausgabe['Punkte'],"</td>","<td><div class=text>",$Ausgabe['Mitspieler'];
print("&nbsp;&nbsp;(");
echo "",$Ausgabe['Spiele'],"";
print(")");
echo "</td></tr>";}
echo "</table>";
echo "</td><td valign=top>";
print("<div class=text>Tageswertung 38. Spieltag</div><br><br>");

$QueryT="Select Mitspieler,sum(Punkte) as Punkte from Tippspiel1011 where Spieltag=38 group by Mitspieler";
$ResultT=mysql_db_query("DB127817",$QueryT,$Link);

while($Row=mysql_fetch_array($ResultT))
{
$GesamtT[] = array('MitspielerT' => $Row[Mitspieler], 'PunkteT' => $Row[Punkte]);
       }

foreach ($GesamtT as $keyT => $rowT) {
    $PunkteT[$keyT]  = $rowT['PunkteT'];
    $MitspielerT[$keyT] = $rowT['MitspielerT'];
}
array_multisort($PunkteT, SORT_DESC, $MitspielerT, SORT_ASC, $GesamtT);

echo "<table>";
foreach($GesamtT as $Ausgabe)
  echo "<tr><td width=25pxl><div class=text>",$Ausgabe['PunkteT'],"</td>","<td><div class=text>",$Ausgabe['MitspielerT'],"</td></tr>";
echo "</table>";

echo "</td></table>";

  mysql_close($Link);
?>

</body>
</html>