"; switch ($action) { Case "addMachineForm": if (isset($_SESSION['loggedinadmin'])) { showAddMachineForm(); } break; Case "editMachineForm": if (isset($_SESSION['loggedinadmin'])) { $machineID = $_GET['machineID']; showEditMachineForm($machineID); } break; Case "addMachine": if (isset($_SESSION['loggedinadmin'])) { if ($_POST['machineName'] != '') { addNewMachine(); } else { echo "Missing information. Please go back and complete the form."; } } break; Case "updateMachine": if (isset($_SESSION['loggedinadmin'])) { $machineID = $_POST['machineID']; if (($_POST['machineName'] != '') OR ($machineID != 0 )) { updateMachine($machineID); } else { echo "Missing information. Please go back and complete the form."; } } break; Case "viewMachines": if (isset($_SESSION['loggedin'])) { $playerID = ""; If (isset($_GET['playerID'])) { $playerID = $_GET['playerID']; } showMachines($playerID); } break; Case "viewMachine": if (isset($_SESSION['loggedin'])) { $machineID = $_GET['machineID']; showMachine($machineID); } break; Case "viewAllMachines": if (isset($_SESSION['loggedin'])) { showAllMachines(); } break; Case Null: Default: showUniqueMachines(); break; } mysql_close(); echo ""; include 'footer.php'; Function showAddMachineForm() { echo "

Add New Machine

"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Name
Acronym
Owner
Software Version
IPDB link #
Image
Is Active"; echo "YES"; echo "NO"; echo "
Notes
"; echo ""; echo ""; echo "
"; } Function showEditMachineForm($machineID) { $sql = "SELECT * FROM P_machines WHERE machineID = ".$machineID; $response = mysql_query($sql); echo "

Edit Machine

"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Name
Acronym
Owner
Software Version
IPDB link #
Image
Is Active"; echo "YES"; echo "NO"; echo "
Notes
"; echo ""; echo ""; echo ""; echo "
"; } Function showMachine($machineID) { $sql = "SELECT * FROM P_machines m JOIN P_players p ON m.ownerID = p.playerID WHERE machineID = ".$machineID; $response = mysql_query($sql); echo "

View Machine

"; echo "
"; echo "
"; echo ""; echo "
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; if (mysql_result($response, 0, "m.isActive") == 1) { echo ""; } else { echo ""; } echo ""; echo "
Machine ID".mysql_result($response, 0, "machineID")."
Name".mysql_result($response, 0, "m.name")."
Acronym".mysql_result($response, 0, "acronym")."
Owner".mysql_result($response, 0, "p.FName")." ".mysql_result($response, 0, "p.LName")."
Software Version".mysql_result($response, 0, "softwareVersion")."
IPDBView at IPDB
StatusActive
StatusNot Active
Notes".mysql_result($response, 0, "m.notes")."
"; if (isset($_SESSION['loggedinadmin'])) { echo "


"; } } Function AddNewMachine() { foreach ($_POST as $key => $value) { echo $key; echo " - "; echo $value; echo "
"; } $sql = "INSERT INTO P_machines (" ."name, acronym, softwareVersion, ownerID, isActive, notes, URL, pictureID) " ."VALUES (" ."'$_POST[machineName]', '$_POST[machineAcronym]', " ."'$_POST[machineSoftwareVersion]', '$_POST[machineOwnerID]', " ."'$_POST[machineIsActive]', '$_POST[machineNotes]', " ."'$_POST[machineIPDBLink]', '$_POST[machinePictureID]') "; $retval = mysql_query( $sql); if(! $retval ) { die('Could not enter data: ' . mysql_error()); } echo "Entered data successfully\n"; $machineID = mysql_insert_id(); return $machineID; } Function UpdateMachine($machineID) { foreach ($_POST as $key => $value) { echo $key; echo " - "; echo $value; echo "
"; } $sql = "UPDATE P_machines SET " ."name = '$_POST[machineName]', " ."acronym = '$_POST[machineAcronym]'," ."softwareVersion = '$_POST[machineSoftwareVersion]'," ."ownerID = '$_POST[machineOwnerID]'," ."isActive = '$_POST[machineIsActive]'," ."notes = '$_POST[machineNotes]'," ."URL = '$_POST[machineIPDBLink]'," ."pictureID = '$_POST[machinePictureID]'" ." WHERE machineID = ".$machineID; $retval = mysql_query( $sql); if(! $retval ) { echo $sql; die('Could not update data: ' . mysql_error()); } echo "Updated data successfully."; } Function showAllMachines() { echo "

All Machines

"; $sql = "SELECT * FROM P_machines m JOIN P_players p ON m.ownerID = p.playerID ORDER BY m.name "; $response = mysql_query($sql); $i=0; $Max=mysql_numrows($response); echo ""; While ($i < $Max) { echo ""; echo ""; echo ""; echo ""; if (isset($_SESSION['loggedin'])) { echo ""; } else { echo ""; } echo ""; $i = $i + 1; } echo "
NameAcronymOwner
".mysql_result($response, $i, "m.name")."".mysql_result($response, $i, "acronym")."".mysql_result($response, $i, "p.FName")." ".mysql_result($response, $i, "p.LName")."".mysql_result($response, $i, "p.initials")."
"; } //list of machines owned by player Function showMachines($playerID) { if (isset($_SESSION['loggedin'])) { $sql = "SELECT * FROM P_machines m JOIN P_players p ON m.ownerID = p.playerID WHERE p.playerID=$playerID ORDER BY m.name "; $response = mysql_query($sql); $i=0; $Max=mysql_numrows($response); if($Max > 0) { echo "

Machines owned by ".mysql_result($response, 0, "p.FName")." ".mysql_result($response, 0, "p.LName")." (".mysql_result($response, 0, "p.initials").")

"; echo ""; While ($i < $Max) { echo ""; echo ""; echo ""; echo ""; echo ""; $i = $i + 1; } echo "
NameAcronym
".mysql_result($response, $i, "m.name")."".mysql_result($response, $i, "acronym")."
"; } else { echo "No machines listed for this player."; } } } function showUniqueMachines() { echo "

Pinball Machines

"; echo "

Here's a list of all the different machines the league gets to play on:

"; $sql = "SELECT DISTINCT m.name, acronym FROM P_machines m JOIN P_players p ON m.ownerID = p.playerID AND m.isActive = '1' ORDER BY m.name "; $response = mysql_query($sql); $i=0; $Max=mysql_numrows($response); echo ""; While ($i < $Max) { echo ""; echo ""; echo ""; echo ""; $i = $i + 1; } echo "
NameAcronym
".mysql_result($response, $i, "m.name")."".mysql_result($response, $i, "acronym")."
"; } ?>