Ich möchte gerne diese Liste nach Spielernnamen sortieren. Nun habe ich aber das Problem, dass ganz oben (wo 0.) ein Spieler steht der da gar nicht hingehört. Ich finde den verdammten Fehler nicht.
Hier der Code
Hier wie es momentan aussieht: http://www.tennis-handicapping.com/players.php
Hier der Code
PHP-Code:
<?php
////////// RECORD /////////
$keywords = preg_split ("/ over/", "martin over test");
$i=0;
$playerlist = array();
$playerlist2 = array();
$result = mysql_query("SELECT bet FROM records ORDER BY recordsID ASC");
while ($records = mysql_fetch_array($result)) {
$split = preg_split("/ over/", $records[bet]);
if (substr_count($records[bet], "over") != 0) {
$playerlist[$i] = $split[0];
$i++;
$playerlist[$i] = $split[1];
}
}
$playerlist = array_unique($playerlist);
sort($playerlist);
while(list($key, $val) = each($playerlist)) {
$playerlist2[$key][0]=$val;
$playerlist2[$key][1]=0;
$playerlist2[$key][2]=0;
$playerlist2[$key][3]=0;
}
$result = mysql_query("SELECT bet,wl,profit,stake FROM records ORDER BY recordsID ASC");
while ($records = mysql_fetch_array($result)) {
$split = preg_split("/ over/", $records[bet]);
if (substr_count($records[bet], "over") != 0) {
$key = array_search($split[0], $playerlist);
$key2 = array_search($split[1], $playerlist);
if ($records[wl] == "W") {
$playerlist2[$key][1]=$playerlist2[$key][1]+1;
$playerlist2[$key2][2]=$playerlist2[$key2][2]+1;
$profit = substr ($records[profit], 0, 1);
$realprofit = substr ($records[profit], 1);
$playerlist2[$key][3]=$playerlist2[$key][3] + $realprofit;
$playerlist2[$key2][3]=$playerlist2[$key2][3] - $records[stake];
}
if ($records[wl] == "L") {
$playerlist2[$key][2]=$playerlist2[$key][2]+1;
$playerlist2[$key][3]=$playerlist2[$key][3] - $realprofit;
}
}
}
sort($playerlist2);
while(list($key, $val) = each($playerlist2)) {
echo "$key: $val[0] $val[1] - $val[2] $"."$val[3]<br/>";
}
?>
Hier wie es momentan aussieht: http://www.tennis-handicapping.com/players.php
Kommentar