function GetTeam($inId = null, $inTeamName = null, $inCoachName = null, $inSquadId = null) { $sq = new Squad(null, null); $db = new MySQL("localhost", "root", "n4UVFpHeHr", "bulilit"); $db->connect(); $s = new SquadDao($db, $sq); if (!empty($inId)) { $query = $db->query("SELECT * FROM Team T WHERE T.TeamID=" . $inId . " ORDER BY T.TeamID DESC") or die("Error retrieving team with team id" . $inId); } else { if (!empty($inTeamName)) { $query = $db->query("SELECT * FROM Team T WHERE T.TeamName like '%" . $inTeamName . "%' ORDER BY T.TeamID ASC"); } else { if (!empty($inCoachName)) { $query = $db->query("SELECT * FROM Team T where T.TeamID in(SELECT TC.TeamID FROM TeamCoach TC where TC.CoachID in (SELECT C.CoachID FROM Coach C where C.Name like '%" . $inCoachName . "%')) ORDER BY T.TeamID"); } else { //$query = mysql_query("SELECT * FROM Team T ORDER BY T.TeamName ASC") or die ("asdfa123123123"); $query = $db->query("SELECT * FROM Team T ORDER BY T.TeamName ASC"); } } } $teamArray = array(); while ($row = mysql_fetch_assoc($query)) { $teamId = $row["TeamID"]; $myCoachArray = GetCoach(null, null, null, $teamId); $mySquadArray = $s->GetSquad(null, null, $teamId); $myTeam = new Team($row["TeamID"], $row['TeamName'], $row['SportID'], $myCoachArray, $mySquadArray); array_push($teamArray, $myTeam); } return $teamArray; }
function EditCompetition($inCompetitionId = null, $inTeamId = null, $inCompName = null, $inDate = null, $inTime = null, $inVenue = null, $inMembers = null, $inPoints = null, $inRolePositions = null) { $query = mysql_query("UPDATE bulilit.TeamCompetitionHistory T SET T.CompetitionID=" . $inCompetitionId . ", T.TeamID=" . $inTeamId . ", T.CompName='" . $inCompName . "', T.Date='" . $inDate . "', T.Time='" . $inTime . "', T.Venue='" . $inVenue . "' WHERE T.CompetitionID=" . $inCompetitionId) or die("<p class='error'>Sorry, we were unable to update the competition to the database.</p>"); $headCoachId = GetCoach(null, null, null, $inTeamId = null); if (isset($inPoints)) { for ($i = 0; $i <= count($inMembers) - 1; $i++) { EditCompetitionMembers($inCompetitionId, $inMembers[$i], $headCoachId[0]->id, $inPoints[$i], $inRolePositions[$i]); } } else { for ($i = 0; $i <= count($inMembers) - 1; $i++) { EditCompetitionMembers($inCompetitionId, $inMembers[$i], $headCoachId[0]->id, 0, $inRolePositions[$i]); } } return true; }
"/><br> Select a Head Coach:<br /> <select name="coach" onchange="filterList(1)"> <?php $coach = GetCoach(); echo '<option value="0" id="0">Select Here</option>'; foreach ($coach as $c) { $coachId = $c->id; $name = $c->name; echo '<option value="' . $coachId . '" id="' . $coachId . '">' . $name . '</option>'; } ?> </select> Please choose the Sub-Coaches:<br /> <?php $subcoach = GetCoach(); foreach ($subcoach as $sc) { $coachId = $sc->id; $name = $sc->name; echo '<div id="' . $coachId . '"><input type="checkbox" id="' . $coachId . '" value="' . $coachId . '" name="subCoaches[]" onclick="filterList(2)">' . $name . '<br /></div>'; } ?> <div class="btnAdd"> <input type="submit" /> </div> </form> </div> <?php } }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <link href="../style.css" rel="stylesheet" type="text/css" /> </head> <body> <?php include 'DAO/coachDao.php'; $coachId = $_GET["coachId"]; $coaches = GetCoach($coachId); foreach ($coaches as $c) { $coachName = $c->name; $userType = $c->userType; } if ("Edit" == $_POST["submit"]) { $coachId = $_POST["coachId"]; $coachName = $_POST["name"]; $userType = $_POST["userType"]; $squadId = $_POST["squadId"]; $coachId = $_POST["coachId"]; $sport = $_POST["sport"]; EditCoach($coachId, $coachName, $userType); echo "You have successfully edited " . $coachName . "!"; echo '<br>'; echo "<a href='/coach/searchCoach.php'>back to search</a>"; } else { if ($coachId == null) { echo "No Coach was selected, you're not supposed to be here!"; } else { echo '<div class="editCoachForm">';
$coachMobileNo = $_POST["mobileNo"]; $coachEmail = $_POST["email"]; if (isset($coachId)) { EditCoach($coachId, $coachName, $coachSSSNo, $coachAddress, $coachTelNo, $coachMobileNo, $coachEmail); } else { AddCoachDetails($id, $coachAddress, $coachTelNo, $coachMobileNo, $coachEmail); } echo 'You have successfully added coach ' . $coachName . '!'; echo '<br />'; echo 'You have set the coach\'s SSS No as ' . $coachSSSNo . '.'; } else { ?> <?php $coachId = $_GET["coachId"]; if (isset($coachId)) { $coach = GetCoach($coachId); foreach ($coach as $c) { $coachName = $c->name; $coachSSSNo = $c->SSSNo; $coachAddress = $c->address; $coachTelNo = $c->telNo; $coachMobileNo = $c->mobileNo; $coachEmail = $c->email; } } else { $coachName = null; $coachSSSNo = null; $coachAddress = null; $coachTelNo = null; $coachMobileNo = null; $coachEmail = null;
foreach ($deleteCoaches as $deleteCoach) { DeleteCoach($deleteCoach); } if ($coachId != null) { $coaches = GetCoach($coachId, null, null); } else { if ($coachName == null && $userType == null) { $coaches = GetCoach(); } else { if ($coachName != null && $userType != null) { $coaches = GetCoach(null, $coachName, $userType); } else { if ($coachName != null) { $coaches = GetCoach(null, $coachName, null); } else { $coaches = GetCoach(); } } } } $counter = 0; foreach ($coaches as $coach) { $id = $coach->id; if ($counter % 2 == 1) { echo "<tr class='alt'>"; } else { echo "<tr>"; } $counter++; ?> <?php