public function selectByNumber($con, $compid, $number) { base::checkcon($con, __FUNCTION__); $sql = "select ID from matches where CompetitionID = {$compid} and Number = {$number}"; $result = mysqli_query($con, $sql); if (!$result) { die('Error: ' . mysqli_error($con)); } $row = mysqli_fetch_array($result); if ($row == null) { return null; } else { return match::select($con, $row['ID']); } }
<?php require_once 'lib/db.php'; require_once 'lib/competition.php'; require_once 'lib/team.php'; require_once 'lib/game.php'; $con = DB::connect(); $matchid = $_GET["match"]; $match = match::select($con, $matchid); $number = $match->Number; session_start(); $compid = $_SESSION["competitionid"]; $comp = competition::select($con, $compid); $prevmatch = match::selectByNumber($con, $compid, $number - 1); $nextmatch = match::selectByNumber($con, $compid, $number + 1); include 'header.php'; include 'navbar.php'; $red = $match->RedAlliance; $blue = $match->BlueAlliance; ?> <label class="heading">Match <?php echo $number; ?> </label><br/> <br/> <table class='scout_table'> <tr> <td class='team red'><?php echo $red->TeamOne; ?> </td>
print ", "; } print "{$property} = {$value}"; $first = false; } } print "\n"; } } function reportMatch($match) { $red = $match->RedAlliance; $blue = $match->BlueAlliance; printf("{$match->ID}, {$match->Time}, {$match->Number}, {$red->TeamOne}, {$red->TeamTwo}, {$red->TeamThree}, " . "{$blue->TeamOne}, {$blue->TeamTwo}, {$blue->TeamThree}, {$red->Points}, {$blue->Points}\n"); } $match = match::select($con, 42); $team = team::selectTeam($con, 1425); // reportMatch($match); if ($match == null) { die("match not found."); } if ($team == null) { die("team not found."); } // reportMatch($match); printf("match = %s, team = %s\n", $match->ID, $match->Number); /* $game = new game(); $game->MatchID = $match->ID; $game->MatchNumber = $match->Number; $game->TeamNumber = $team->Number;