Esempio n. 1
0
//generate current pool scores (this comes as sorted from highest scorer to lowest)
$counter = 0;
//define this so we know which iteration of the below foreach statement we are in
$counter_interval = 0;
//we use this to keep track of the number of users tied in a given position.
//for instance, if 3 users all have the same score, this value will become 3 as we go thru each of the 3 tied users' ranks
//this way, when we get to the next user after the 3 tied users, we can make that users rank 3 more than the tied users' rank
$pool_sorting_array = array();
//below foreach will sort the array of pool members according to their score:
foreach ($pool_scores_result as $user_id => $user_score) {
    $pool_sorting_array[$user_id] = $pool_members_array_for_table[$user_id];
}
$pool_sorting_array_keys = array_keys($pool_sorting_array);
//now that we have the pool members sorted based on their score, let's create the pool members table:
foreach ($pool_sorting_array as $user_id => $tie_breaker_answer) {
    $user_info = $user->GetUserInfo($user_id);
    //get the given user's username and email address and store them in the user_info array
    if ($pool_members_id_array[$user_id]['Nickname'] == "no_nickname") {
        $nickname = $user_info['Email Address'];
    } else {
        $nickname = $pool_members_id_array[$user_id]['Nickname'];
    }
    $pool_members_array[$user_id] = $user_info;
    //stores user's username and email address in pool_members_array (array key is user id).  THIS CAN BE USED OUTSIDE OF FOREACH LOOP
    ?>
        <tr>
            <td class="pool_member_table_rank" style="<?php 
    echo $pool_member_table_rank_style;
    ?>
"><?php 
    echo $counter + 1;
Esempio n. 2
0
 public function GetPoolWinners()
 {
     $number_to_return = 5;
     //SET THE NUMBER OF WINNERS TO BE RETURNED BY THIS FUNCTION HERE
     //GET RECENT WINNERS FROM POOL TABLE
     include_once 'inc/class.users.inc.php';
     //we only use this in case we need to get the given winner's email address if they didnt specify a pool nickname
     $user = new SiteUser();
     //new user instance
     $query = new DB_Queries();
     //new instance of the DB_Queries object
     $recent_winners_query = "SELECT * FROM  `Pool` WHERE `Pool Winner` IS NOT NULL ORDER BY `Pool ID` DESC LIMIT 0,{$number_to_return};";
     $result1 = mysqli_query($this->cxn, $recent_winners_query);
     //$recent_pools_array = mysqli_fetch_assoc($result1);
     $pool_winner_array = array();
     while ($row = mysqli_fetch_assoc($result1)) {
         $pool_id = $row['Pool ID'];
         $winner_user_id = $row['Pool Winner'];
         $select_array = $this->CreateArrayFromDB_QueryInputs('Pool Nickname', 'TABLE:', 'Pool Membership', 'User ID', $winner_user_id, 'Pool ID', $pool_id);
         $nickname_array = $query->SelectFromDB($select_array);
         if (is_null($nickname_array['Pool Nickname'])) {
             //if no pool nickname was set, return the winner's numeric user ID #:
             $user_info = $user->GetUserInfo($winner_user_id);
             $pool_winner_array[$pool_id] = $user_info['Email Address'];
         } else {
             //if a pool nickname was set, put in into the pool winner array
             $pool_winner_array[$pool_id] = $nickname_array['Pool Nickname'];
         }
     }
     return $pool_winner_array;
 }