"; switch ($action) { Case "addPlayerForm": if (isset($_SESSION['loggedinadmin'])) { showAddPlayerForm(); } break; Case "editPlayerForm": if (isset($_SESSION['loggedinadmin'])) { $playerID = $_GET['playerID']; showEditPlayerForm($playerID); } break; Case "addPlayer": if (isset($_SESSION['loggedinadmin'])) { if ($_POST['playerFName'] != '') { addNewPlayer(); } else { echo "Missing information. Please go back and complete the form."; } } break; Case "updatePlayer": if (isset($_SESSION['loggedinadmin'])) { $playerID = $_POST['playerID']; IF (($_POST['playerFName'] != '') OR ($playerID != 0 )) { updatePlayer($playerID); } else { echo "Missing information. Please go back and complete the form."; } } break; Case "viewPlayer": $playerID = $_GET['playerID']; showPlayer($playerID); break; Case "viewAllPlayers": if (isset($_SESSION['loggedin'])) { showAllPlayers(); } break; Case Null: Default: showPlayerList(); break; } mysql_close(); echo ""; include 'footer.php'; Function showAddPlayerForm() { echo "

Add New Player

"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
First Name
Last Name
Nickname
HS Initials
Address
Phone Number
Mobile Number
Email Address
Can Host"; echo "YES"; echo "NO"; echo "
(Host Day)
IFPA Number
T-Shirt Size
Notes
"; echo ""; echo ""; echo "
"; } Function showEditPlayerForm($playerID) { $sql = "SELECT * FROM P_players WHERE PlayerID = ".$playerID; $response = mysql_query($sql); echo "

Edit Player

"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
First Name
Last Name
Nickname
HS Initials
Address
Phone Number
Mobile Number
Email Address
Can Host"; echo "YES"; echo "NO"; echo "
(Host Day)
IFPA Number
T-Shirt Size
Is Active"; echo "YES"; echo "NO"; echo "
Notes
"; echo ""; echo ""; echo ""; echo "
"; } Function showPlayer($playerID) { $sql = "SELECT * FROM P_players WHERE PlayerID = ".$playerID; $response = mysql_query($sql); $sql = "SELECT * FROM P_machines WHERE ownerID = ".$playerID; $machinesresponse = mysql_query($sql); $nummachines=mysql_numrows($machinesresponse); if(mysql_numrows($response) == 0) { echo "

Player Not Found

"; }else{ echo "

View Player Information

"; echo ""; echo ""; if (isset($_SESSION['loggedin'])) { echo ""; echo ""; } echo ""; if (isset($_SESSION['loggedin'])) { echo ""; if($nummachines > 0) { echo ""; } } if (isset($_SESSION['loggedinadmin'])) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; IF (mysql_result($response, 0, "Host") == 1) { echo ""; echo ""; } else { echo ""; } IF (mysql_result($response, 0, "isActive") == 1) { echo ""; } else { echo ""; } echo ""; } echo "
First Name".mysql_result($response, 0, "FName")."
Last Name".mysql_result($response, 0, "LName")."
Nickname".mysql_result($response, 0, "Nickname")."
HS Initials".mysql_result($response, 0, "Initials")."
IFPA Number".mysql_result($response, 0, "IFPA")."
Machines Owned: $nummachines
ADMIN ONLY SECTION
Player ID".mysql_result($response, 0, "PlayerID")."
Address".mysql_result($response, 0, "Address1")."
".mysql_result($response, 0, "Address2")."
".mysql_result($response, 0, "Address3")."
".mysql_result($response, 0, "Address4")."
Phone Number".mysql_result($response, 0, "Phone")."
Mobile Number".mysql_result($response, 0, "Mobile")."
Email Address".mysql_result($response, 0, "Email")."
T-Shirt Size".mysql_result($response, 0, "TShirt")."
Can Host".mysql_result($response, 0, "HostDay")."
Cant Host---
StatusActive
StatusNot Active
Notes".mysql_result($response, 0, "Notes")."
"; if (isset($_SESSION['loggedinadmin'])) { echo "


"; } } } Function AddNewPlayer() { foreach ($_POST as $key => $value) { echo $key; echo " - "; echo $value; echo "
"; } $sql = "INSERT INTO P_players (" ."FName, LName, Host, HostDay, Email, Address1, " ."Address2, Address3, Address4, Nickname, Initials, Phone, Mobile, TShirt, IFPA, Notes) " ."VALUES (" ."'$_POST[playerFName]', '$_POST[playerLName]', " ."'$_POST[playerCanHost]', '$_POST[playerHostDay]', '$_POST[playerEmail]', " ."'$_POST[playerAddress1]', '$_POST[playerAddress2]', " ."'$_POST[playerAddress3]', '$_POST[playerAddress4]', " ."'$_POST[playerNickname]', '$_POST[playerInitials]', " ."'$_POST[playerPhone]', '$_POST[playerMobile]', " ."'$_POST[playerSize]', " ."'$_POST[playerIFPA]', '$_POST[playerNotes]') "; $retval = mysql_query( $sql); if(! $retval ) { die('Could not enter data: ' . mysql_error()); } echo "Entered data successfully\n"; $playerID = mysql_insert_id(); return $playerID; } Function UpdatePlayer($playerID) { foreach ($_POST as $key => $value) { echo $key; echo " - "; echo $value; echo "
"; } $sql = "UPDATE P_players SET " ."FName = '$_POST[playerFName]', " ."LName = '$_POST[playerLName]'," ."Host = '$_POST[playerCanHost]'," ."HostDay = '$_POST[playerHostDay]'," ."Email = '$_POST[playerEmail]'," ."Address1 = '$_POST[playerAddress1]'," ."Address2 = '$_POST[playerAddress2]'," ."Address3 = '$_POST[playerAddress3]'," ."Address4 = '$_POST[playerAddress4]'," ."Nickname = '$_POST[playerNickname]'," ."Initials = '$_POST[playerInitials]'," ."Phone = '$_POST[playerPhone]'," ."Mobile = '$_POST[playerMobile]'," ."TShirt = '$_POST[playerSize]'," ."IFPA = '$_POST[playerIFPA]'," ."isActive = '$_POST[playerIsActive]'," ."Notes = '$_POST[playerNotes]'" ." WHERE PlayerID = ".$playerID; $retval = mysql_query( $sql); if(! $retval ) { echo $sql; die('Could not update data: ' . mysql_error()); } echo "Updated data successfully."; } Function showAllPlayers() { echo "

All League Players

"; echo "

Here's a list of past and current LOPL players:

"; $sql = "SELECT * FROM P_players ORDER BY isActive, FName, LName "; $response = mysql_query($sql); $i=0; $Max=mysql_numrows($response); echo ""; echo ""; if (isset($_SESSION['loggedinadmin'])) { echo ""; } echo ""; While ($i < $Max) { echo ""; echo ""; echo ""; if (isset($_SESSION['loggedinadmin'])) { echo ""; } echo ""; if(mysql_result($response, $i, "isActive")) { echo ""; } else { echo ""; } echo ""; echo ""; echo ""; echo ""; $i = $i + 1; } echo "
First NameLast NameEmailHS InitialsActiveDetailsScoresRank
".mysql_result($response, $i, "FName")."".mysql_result($response, $i, "LName")."".mysql_result($response, $i, "email")."".mysql_result($response, $i, "Initials")."YesYes
"; } function showPlayerList() { echo "

League Players

"; echo "

Here's a list of active players in the LOPL:

"; $sql = "SELECT * FROM P_players WHERE isActive=1 ORDER BY LName, FName "; $response = mysql_query($sql); $i=0; $Max=mysql_numrows($response); echo ""; While ($i < $Max) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $i = $i + 1; } echo "
First NameHS InitialsDetailsRankLinks
".mysql_result($response, $i, "FName")."".mysql_result($response, $i, "Initials")."
"; } ?>