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); // $newGame = $db->addData($game_id, $_POST['away_id'], $_POST['home_id'], $gameWeek, $_POST['game_date'], $_POST['game_time'], $_POST['facility'], $_POST['area']); // $school_name = 'All'; } elseif (isset($_POST['delete_game'])) { // get the page that sent here $referer = $_SERVER['HTTP_REFERER']; //get game id $game_id = $_POST['game_id']; // get away team name $away_team = $_POST['away_team']; // get home team name $home_team = $_POST['home_team']; //delete game with that id $deleteGame = $db->deleteData($game_id, $away_team, $home_team); // send the page back where it came from header("Location: {$referer}");