All pastes #416297 Raw Edit

Someone

public text v1 · immutable
#416297 ·published 2007-03-30 05:31 UTC
rendered paste body
  if ($varLadder) {
    $queryLadderPlayers = mysql_query("SELECT players FROM ladder WHERE id = '" . $varLadder . "'") or die;
    $queryLadderPlayers = mysql_fetch_row($queryLadderPlayers);
    $ladderPlayersArray = explode("|", $queryLadderPlayers[0], -1);
    
    echo "<ul style=\"margin-left: 30px; list-style: none\">\n";
    echo "  <li class=\"ladderTitleSmall\">\n";
    echo "    Rank\n";
    echo "  </li>\n";
    echo "  <li class=\"ladderTitleName\">\n";
    echo "    Players\n";
    echo "  </li>\n";
    echo "  <li class=\"ladderTitleSmall\">\n";
    echo "    Wins\n";
    echo "  </li>\n";
    echo "  <li class=\"ladderTitleSmall\">\n\n";
    echo "    Losses\n";
    echo "  </li>\n";
    echo "  <li class=\"ladderTitleSmall\">\n\n";
    echo "    Streak\n";
    echo "  </li>\n";
    echo "  <li class=\"ladderTitleBig\">\n";
    echo "    Percentage\n";
    echo "  </li>\n";
    echo "  <li class=\"ladderTitleSmall\">\n";
    echo "    Team\n";
    echo "  </li>\n";
    echo "  <li class=\"ladderTitleSmall\">\n";
    echo "    Flag\n";
    echo "  </li>\n";

    for($ladderPlayersCount = 0; $ladderPlayersCount < count($ladderPlayersArray); $ladderPlayersCount++) {

      $ladderPlayerCurrent = $ladderPlayersArray[$ladderPlayersCount];
      $queryLadderWins = mysql_query("SELECT game FROM ladder WHERE winner = '" . $ladderPlayerCurrent . "'") or die;
      $playerWins = 0;

      while ($ladderWinsArray = mysql_fetch_array($queryLadderWins, MYSQL_ASSOC)) {
        foreach ($ladderWinsArray as $ladderWins) { $playerWins++; }
      }
        
      $queryLadderWinner = mysql_query("SELECT winner FROM ladder WHERE challenger = '" . $ladderPlayerCurrent . "' OR opponent = '" . $ladderPlayerCurrent . "' ORDER BY timestamp DESC") or die;
      $playerLosses = 0;
      $playerStreak = 0;
      $playerStreakLost = 0;
      
      while ($ladderWinnerArray = mysql_fetch_array($queryLadderWinner, MYSQL_ASSOC)) {
        foreach ($ladderWinnerArray as $ladderWinner) {
          $playerLosses++;
          if (!$playerStreakLost) {
            if ($ladderWinner == $ladderPlayerCurrent) {
              $playerStreak++;
            } else {
              $playerStreakLost = 1;
            }
          }
        }
      }
      
      $playerLosses -= $playerWins;
      $playerPercentage = ($playerWins / ($playerWins + $playerLosses)) * 100;
      $playerPercentage .= "%";
      
      echo "  <li class=\"ladderSmall ladderClear\">\n";
      echo "    0\n";
      echo "  </li>\n";
      echo "  <li class=\"ladderName\">\n";
      echo "    $ladderPlayerCurrent\n";
      echo "  </li>\n";
      echo "  <li class=\"ladderSmall\">";
      echo "    $playerWins\n";
      echo "  </li>\n";
      echo "  <li class=\"ladderSmall\">\n";
      echo "    $playerLosses\n";
      echo "  </li>\n";
      echo "  <li class=\"ladderSmall\">\n";
      echo "    $playerStreak\n";
      echo "  </li>\n";
      echo "  <li class=\"ladderBig\">";
      echo "    $playerPercentage\n";
      echo "  </li>\n";
      echo "  <li class=\"ladderSmall\">";
      echo "    Team\n";
      echo "  </li>\n";
      echo "  <li class=\"ladderSmall\">";
      echo "    Flag\n";
      echo "  </li>\n";
    }
    echo "</ul>";
  }