// check if there's a winner // set winner to null $_win = NULL; // if there's a final score if ($_POST['away_final'] != '' && $_POST['home_final'] != '') { // check for a tie if ((int) $_POST['away_final'] == (int) $_POST['home_final']) { $_win = 'TIE'; } elseif ((int) $_POST['away_final'] > (int) $_POST['home_final']) { $_win = $_POST['update_away_team']; } else { $_win = $_POST['update_home_team']; } } // update with new data $gameScore = $db->inputDataAway($_POST['game_id'], $_POST['area'], $_POST['game_date'], $_POST['game_time'], $_POST['update_away_team'], $_POST['update_home_team'], $_POST['facility'], $_win, $_POST['q1_away'], $_POST['q2_away'], $_POST['q3_away'], $_POST['q4_away'], $_POST['ot_away'], $_POST['q1_home'], $_POST['q2_home'], $_POST['q3_home'], $_POST['q4_home'], $_POST['ot_home'], $_POST['away_team'], $_POST['home_team'], $_POST['away_final'], $_POST['home_final']); // send back to page that called update header("Location: {$referer}"); } elseif (isset($_POST['add_game'])) { // i really don't know what this does $flag = "input"; // get day of game $updated_day = $_POST['game_date']; // get the week of game $gameWeek = getGameWeek(str_replace("-", "/", $updated_day)); // get the new game id request $getID = "SELECT CONVERT(SUBSTRING_INDEX(game_id,'_',-1),UNSIGNED INTEGER) AS num\n\t\t\t\tFROM schedule_2015\n\t\t\t\tWHERE week = '{$gameWeek}'\n\t\t\t\tORDER BY num DESC\n\t\t\t\tLIMIT 1;"; // request the id $id = $db->getData($getID); // make new unique id $game_id = "wk" . $gameWeek . "_" . ($id[0]['num'] + 1);