<?php # Only show the challenge form if the user is logged into a valid account. if ($validUser) { # Only show the form to report scores if the user has an active challenge. if (hasActiveChallenge($username, $connection)) { # Get the information for the active challenge. $challenge = getActiveChallenge($username, $connection); $challengerName = $challenge[0]; $challenger = $challenge[3]; $opponent = $challenge[5]; ?> <div class="widget"> <div class="widgetTitle"> <img src="includes/images/graphics/body/titleBand.png" class="goldband" /> <h2>Report Challenge Scores</h2> </div> <div class="widgetContent"> <p class="centerText italic">Report scores for your games against <?php echo $challengerName; ?> .</p> <p class="centerText italic small">Required fields are marked with <span class="red">*</span></p> <div id="errors" class="centerText"> </div> <form action="includes/scripts/php/submitScores.php" method="POST" onsubmit="return valGameScores()"> <input type="hidden" name="player" id="player" value="<?php
function getPlayerStandings($username, $userRank, $connection) { # Get all active users from the database. $getUsers = mysqli_query($connection, "SELECT * FROM player WHERE rank > 0 ORDER BY rank") or die(mysqli_error($connection)); # Add all users to an array that includes their name and rank. $contestants = array(); while ($playerInfo = mysqli_fetch_array($getUsers)) { # Determine if the current contestant is able to be challenged by the # player who is currently logged in. A player can be challenged if they # are within three ranks above a user, have no active challenges, and the # challenging player has no active challenges. $canChallenge = $playerInfo['rank'] < $userRank && $playerInfo['rank'] >= $userRank - 3 && !hasActiveChallenge($playerInfo['username'], $connection) && !hasActiveChallenge($username, $connection); $contestants[] = array("name" => $playerInfo['name'], "username" => $playerInfo['username'], "rank" => $playerInfo['rank'], "challenge" => $canChallenge); } return $contestants; }