function showLeaderboard($boardId) { $boardquery = mysql_query("SELECT * FROM leaderboards WHERE leaderboardid = '{$boardId}'"); $board = mysql_fetch_array($boardquery); $boardName = $board['title']; $boardDescrip = $board['description']; $boardHighscore = $board['highscore']; $boardLength = $board['length']; echo "<b>{$boardName}:</b> {$boardDescrip}<br>"; $pos = 1; if ($boardHighscore = 1) { $scorequery = mysql_query("SELECT * FROM scores WHERE score > '0' and gameid = '3' and leaderboardid = '{$boardId}' ORDER BY score DESC LIMIT {$boardLength}"); } else { $scorequery = mysql_query("SELECT * FROM scores WHERE score > '0' and gameid = '3' and leaderboardid = '{$boardId}' ORDER BY score ASC LIMIT {$boardLength}"); } if (mysql_num_rows($scorequery) != 0) { echo '<table class="table table-striped"> <thead> <tr> <th width="20">#</th> <th width="200">Username</th> <th width="200">Score</th> </tr> </thead> <tbody>'; } else { echo '<small><i>This leaderboard is empty</i></small>'; } while ($row = mysql_fetch_array($scorequery)) { echo '<tr>'; echo '<td>' . $pos . '</td>'; echo '<td><img class="img-rounded" src="' . getGravatarUrlFromEmail(getUserEmailFromName($row['username']), 20) . '"> <a href="profile.php?id=' . getUserIdFromName($row['username']) . '">' . $row['username'] . '</a></td>'; echo '<td>' . $row['score'] . '</td>'; echo '</tr>'; $pos += 1; } echo '</tbody>'; echo '</table>'; }
<?php // Inialize session session_start(); // Load config include '../../../config.php'; // Get user id from username $userId = getUserIdFromName($_GET['user']); // Return info echo $userId; function getUserIdFromName($name) { // Load user info $userData = mysql_query("SELECT * FROM users"); // Search for username and return id while ($row = mysql_fetch_array($userData)) { if ($row['username'] == $name) { return $row['id']; } } }
<?php } else { ?> <i class="icon-star"></i> <?php echo getNumberAchievements(); ?> achievements<br><br> <?php } ?> </div> <div class="span9"> <div class="row"> <h2>Recent activity</h2> <?php $userid = getUserIdFromName($username); $session = mysql_query("SELECT * FROM sessions WHERE userid = '{$userid}'"); $row = mysql_fetch_array($session); $gameid = $row['gameid']; if (getGameTitleFromId($gameid) == "") { echo $username, " has no recent activity"; } else { echo $username, " was most recently seen playing <a href=\"viewgame.php?id=", $gameid, "\">", getGameTitleFromId($gameid), "</a>"; } ?> </div> <div class="row"> <br><br><br><br><br> <center><h3>More profile data coming soon.</h3></center> </div> </div>
function reconcileWinners($db, $winner, $group_id, $season_year, $season_type, $week, $verbose = FALSE) { //New streamlined reconciliation process, added 8/22/15, this just sets the falgs in the db $sql = "UPDATE points SET reconciled=1, winner=1 WHERE user_id='" . getUserIdFromName($db, $winner) . "' AND group_id='" . $group_id . "' AND season_year='" . $season_year . "' AND season_type='" . $season_type . "' AND week='" . $week . "'"; if (mysqli_query($db, $sql)) { if ($verbose) { echo "And has been reconciled in the database. {$sql}<br>\n"; } } else { echo mysqli_error($db); } //Set all users for that week as reconciled also, just with NULL winner $sql = "UPDATE points SET reconciled=1 WHERE group_id='" . $group_id . "' AND season_year='" . $season_year . "' AND season_type='" . $season_type . "' AND week='" . $week . "'"; if (mysqli_query($db, $sql)) { if ($verbose) { echo "The other loser have also been reconciled in the database. {$sql}<br>\n"; } } else { echo mysqli_error($db); } }